TFS 2015 Custom build variables not included as environment variables TFS 2015 Custom build variables not included as environment variables powershell powershell

TFS 2015 Custom build variables not included as environment variables


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, i.e. %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.