Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update or add an Environment Variable to a TeamCity agent

Tags:

TeamCity agent's show a list of "Environment Variables" under Agent Parameters but I cannot get them to update. I've added environment variables to my agent operating system, but cannot get them to refresh. I've tried restarting the agent and disabling and re-enabling the agent.

like image 226
James Avatar asked Mar 24 '16 10:03

James


People also ask

How do I add an agent on TeamCity?

Open the Agents page in TeamCity. Click Install Build Agents and select Windows Installer to download the installer. On the agent machine, run agentInstaller.exe and follow the installation instructions.


1 Answers

The TeamCity agent doesn't actually read environment vars from the OS. Instead it reads them from the buildAgent/conf/buildAgent.properties file on your agent machine. Down at the bottom of this file you'll see instructions on how to add new variables. Something like this:

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

Once you'ce done this switch to command prompt on your agent machine, and execute something like this:

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

Obviously OS dependant. There is a .bat file there for Windows.

That should get your Environment variables showing up in TeamCity.

like image 90
James Avatar answered Sep 19 '22 11:09

James