Set environment and properties for TeamCity build agent. Reconnect. Use them in projectsBy neokrates, written on May 20, 2010
We start with TC master, two build agents and one project. Perpose is to introduce new system variable, let us call it exclusion.criteria. If it is defined, our project should not use the agent for the builds.
✔ TeamCity 4.x
Should also work for:
✔ TeamCity 2.x, 3.x, 5.x etc
Login to TeamCity agent host.
Then, add new variable into TeamCity agent config file:
⚠ IMPORTANT Prefix might be either system. or env. Both can be used from the project.
Activate new property. Reconnect the agent
Agent can be reconnected per command line restart, something like:
1 2 3 4 5 6 7 8
$TC_AGENT_HOME/bin/agent.sh stop Stopping TeamCity build agent... Sending agent shutdown command to: http://localhost:10403 Shutdown command successfully sent. Agent will exit when idle. $TC_AGENT_HOME/bin/agent.sh start Starting TeamCity build agent... Done , see log at ../logs/teamcity-agent.log
💡 REMARK. Often, the /etc/init.d/ is used to demonize and configure the agent.
Connect the agent
Agent should appear in TeamCity in Agents -> Connected Agents.
If it is not the case, you might find it in Agents -> Unauthorized Agents
Authorize or activate it.
Setup one build not to build on agents with our property
- Select the project.
- Go to Administration -> Your Project -> You Configuration
- Select Agent requirements
- Under Requirements for system properties, add: system.exclusion.criteria, condition = does not exist
💡 REMARK: You actually enter exclusion.criteria, not _system.exclusion.criteria . Teamcity prefixes itself.
If done right, the agent with property should switch its location in Agents compatibility
Compatible agents -> Incompatible agents
Thats it, have fun!! :-)