How to update or add an environment variable for TeamCity agent

The TeamCity agent displays the list of "Environment Variables" in the agent settings, but I cannot update them. I have added environment variables to my operator operating system, but I cannot update them. I tried restarting the agent and disconnecting and reactivating the agent.

+5
source share
2 answers

The TeamCity agent does not actually read environmental data from the operating system. Instead, it reads them from the buildAgent / conf / buildAgent.properties file on your agent machine. At the bottom of this file you will see instructions for adding new variables. Something like that:

# Environment Variables #env.exampleEnvVar=example Env Value env.GRADLE_HOME=/Frameworks/gradle-2.9 

Once you make this switch on the command line on your agent machine and do something like this:

 ./agent.sh stop ./agent.sh start 

Obviously OS dependent. For Windows there is a .bat file.

This should cause the environment variables to appear in TeamCity.

+8
source

I just tried it in TeamCity 2017.2.1, and machine-level environment variables were collected by TeamCity build agents (as well as buildAgent.properties), so it looks like this has been fixed.

0
source

Source: https://habr.com/ru/post/1245693/


All Articles