Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.
If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!
Read windows environment variable in script
-
I am trying to use an environment variable inside a script but am not getting a value returned. The variable has been set at the machine level.
What does buildmaster do to the environment the script is running under that it cannot pick up environment variables?
Example 1: Running the script manually logged on as the same user that the buildmaster service runs under.
C:\temp>andrew.cmd
EnableNuGetPackageRestore='true'
http_proxy=''
TEST='HELLO'
TEMP='C:\Users\SVC_JE~1\AppData\Local\Temp\2'Example 2: Buildmaster job.
Initialization complete. Executing...
Arguments:
Working Directory:
C:\BuildMaster_SVCTMP_A7_S1032\SRC
Executing c:\temp\andrew.cmd
EnableNuGetPackageRestore=''
Process Exit Code: 0 (0x00000000)
Execution complete. Finalizing...
http_proxy=''
Target directory unused; joining with source.
TEST=''
TEMP='C:\Users\SVC_JE~1\AppData\Local\Temp'
Finalization complete. -
Hi Andrew,
We don't do anything special, just standard Process.Start stuff.
I believe Processes inherit environments from the parent process, so perhaps you need to stop/start the service, so it can capture new machine variables?
FYI - we do have an option (AddBuildMasterVariablesAsEnvironmentVariables) on CommandLineActionBase, but this is not exposed as a checkbox in the Command Line Action. We will likely add that as a checkbox in the future.
Alex
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login