Need a way to reload environment variables for the tentacle

We have a deploy project that needs to set system-wide environment variables that other deployment projects depend on. Unfortunately, any child processes that are started up by the tentacle inherits its environment variables (thanks Microsoft) and we haven’t found a way yet to make it so the tentacle process gets updated. Any suggestions?

Hi @michael-void!

Having hit this myself in a project recently, I had good success in using Chocolatey’s refreshenv command to reload all the environmental variables from the registry. If you don’t/cant install chocolately, you can find the details of their powershell implementation on their GitHub page here: https://github.com/chocolatey/choco/blob/stable/src/chocolatey.resources/helpers/functions/Update-SessionEnvironment.ps1

I hope this helps!

From the synopsis:

Updates the environment variables of the current powershell session with any environment variable changes that may have occured during a Chocolatey package install.

This wouldn’t work for us because we’re needing to update the environment for all subsequent deployments made by the tentacle (many different projects, with many different steps). It is easy enough to reload env variables from powershell, but the tentacle creates a new PS session for every step of the deploy process to execute that step - so any environment changes made are sandboxed to just that step.

The “standard” way to do it for windows would be to broadcast a WM_SETTINGCHANGE message, but the tentacle would need to listen for & handle that event to reload its own environment (this behavior was even pointed out on the choco script you mentioned).

Without a way to tell the tentacle to reload the environment, the only option I can think of at this point is to restart the tentacle service itself - which I haven’t found a way to do without causing the deploy to fail.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.