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


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation