Restricting concurrent builds between multiple agents



We have 5 agents running in its own LXC/Docker container. 3 of them are actually in 'machine A', and the other 2 are also in 'machine B'.

We do not want each machine (A and B) to run too many jobs concurrently. For example, job 1 and 2 can run in machine A and B respectively at the same time, but they should not run in the same machine at the same time.

I tried to achieve this constraint using Shared Resources, but could not figure out how.

I wonder:

  • if there's a way to assign a shared resource to an agent, so that I can assign the same shared resource to the agents running on the same machine, or
  • if I can acquire a shared resource programmatically, so that I can acquire a certain value such as the agent's system property value (i.e. the machine's name) from a custom shared resource (i.e. the list of the machine names (A and B in this case)).



1 comment
Comment actions Permalink

Hello Trustin,

It's not possible to restrict concurrent builds between multiple agents. TeamCity treats all agents equally regardless of whether they are installed on the same or on different machines.

We do not recommend to install several TeamCity agents on the same machine if the machine is not capable of running several builds at the same time. When installing several TeamCity build agents on the same machine, please consider the following:

  • The builds running on such agents should not conflict by any resource (common disk directories, OS processes, OS temp directories).
  • Depending on the hardware and the builds, you may experience degraded builds' performance. Ensure there are no disk, memory, or CPU bottlenecks when several builds are run at the same time.

In your case I would recommend to increase the number of agent machines. 

Also you can use Agent pools to bind specific agents to specific projects.


Please sign in to leave a comment.