Published on

Sharing Variables Across TeamCity build steps


I had to setup a build configuration in TeamCity that used one build step to download a common script and had another that used that script, but after changing to another working directory.

I first tried using a command line variable that was set in the step that downloaded the script but quickly discovered that vanilla bash command line variables are not shared across build steps.

I then tried setting the environment variable using the TeamCity syntax for doing this but still could not get this to work and struggled to find good examples or documentation on how to do this online.

In the end I used the fact that the build steps are in the same root working directory as they are in the same build configuration and ended up using relative paths to point to the script I needed which was a few directories up from my later build step's working directory.