Automated Build Agents Assignment TeamCity

Kamlesh Bhatt
kamlesh_bhatt
Published in
2 min readJan 13, 2020

--

I started using TeamCity from the start of my working life, by now i have used almost all the CI-CD tools like TeamCity, Jenkins, Bamboo, CodeBuild CodeDeploy, Azure DevOps etc. As all of these have the same concept and are equally powerful in their own way , but my personal favourite is Teamcity just for it’s simplicity to use + the integrations with the other third party tools makes it even more powerful.

One can read about TeamCity more, if they haven’t already here.

One big challenge with TeamCity is the free version comes with only 3 build Agents and 100 build configurations.

100 build Configurations are not enough in any way but, if you can design your CI-CD pipeline correctly and efficiently, 100 build configuration are more than enough for a small to medium scale companies.

But when it comes to build agents, then 3 build agents are not enough. If you have wide variety of tech stack in your projects/company; which means you have windows, linux, other builds e.g .net, angular, java, nodejs, docker etc.

Having 3 build agents it will slowly result in longer build queue, delays in build and deployment for which we were TeamCity at first place.

So the question is how we can still use TeamCity without paying few bucks for an extra build agent and still use multiple build agents ?

I have created a simple yet powerful python script which uses TeamCity REST API to automatically authorise and unauthorises the build agents based on the compatible build configurations.

What will Script Do:

  1. Monitor the build queue
  2. As soon as there is a build in the queue, it will check which agents are compatible for it to run
  3. Once the script finds the compatible agents, it will check if any build is running on the any of the agents, if Yes, it will look for other compatible agents, if not then it will automatically Unauthorize the incompatible build agents and authorize the compatible agent from the agents pool

--

--

Kamlesh Bhatt
kamlesh_bhatt

4x AWS Certified | DevOps Engineer | GCP | Azure | Cloud Platform Engineer | Docker | Kubernetes