4
votes

I have a TeamCity project with multiple sub-probjects. How do I get a subproject to run on a specific agent without hard coding it in the agent requirement upfront? I want to do something like..

Team City Agent Requirement

That way instead of copying the subproject for each agent I can just have one project and specify an agent name at execution time in some config. Using TeamCity 9.

2

2 Answers

2
votes

You can create agent pools and assign specific agents to a project. To do this click on the "agents" link at the top .

Basically, you can define that targets of a particular project should only run on particular agent.

EDIT If you want to define it at runtime, you have to go back to defining an agent requirement in the targets. You set a paremeter for agent name in the first target .In all the subsequent targets, you can create build chains and pass parameters from one target to another. In the definition of the target, you set an agent condition saying agent name matches whatever value you are passing in your custom variable In the first target you can have a prompt/dropdown and you can initialize an agent based run for a complete build chain.

Or you can assign and unassign agents from the projects pools before each run and then run the targets. For ex in agent pool you can set Project A to only build on agent 1 . After the run is complete, you change Project A to run only on target2 .

I will recommend the first option over the second

0
votes

This plugin may do what you want. You can define a series of different values for the same parameter(s) and it will run across all of them. This could be agent names or environment variables or node.js versions or whatever.

https://github.com/presidentio/teamcity-matrix-build-plugin