简体   繁体   中英

TFS 2015 Custom build variables not included as environment variables

I have added a custom variable to my build in TFS 2015, however, this variable does not appear in the environment variables when the build is run. I have verified this by running

Get-ChildItem Env:

in the PowerShell script. There is plenty of documentation about the predefined build variables, but the documentation for how to access custom variables is pretty disappointing. Any help would be appreciated.

So I figured it out.

I initially named my variable OCTOPUS_API_KEY . I figured since I would only be accessing it as an environment variable I might as well use the env var naming convention.

Apparently, the names of the custom variables that you define get transformed by some internal undocumented rule described here .

So based on this, I renamed the variable to octopus.api.key and it was properly transformed to the OCTOPUS_API_KEY environment variable and included in the build.

It would seem that the transformation applied to variable names to make them env var friendly doesn't actually handle variables that are already in the right format.

Documentation for build variables is now available and does describe the behavior observed in the question.

All variables are also exported to the environment as uppercase and any . are replaced with _ . In scripts you can reference variables via the environment, ie %VARIABLE_NAME% , $VARIABLE_NAME , $env:VARIABLE_NAME , depending on the operating system.

It's also worth noting that variables marked as "secret" are not exported as environment variables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM