Query Running Agents using REST API

Currently the only way to find out which agents are running builds is to query the running builds, then loop through those build ids to find out which agent is running that build.  There's no way to just ask for a list of running agents.  Even being able to get this info off querying the agents directly would be helpful, instead all you get back from an agent query is the agent id, name, and url.  This is a big flaw in the REST API for me as my use case is automatic adding/removing of build hosts.

I would love it if something like "http://teamcity:8111/httpAuth/app/rest/agents?locator=running:true" could be implemented.


Hi Anne,

You can get the list of builds and agents they run on using the following request:


For more details please see the section in documentation.


Hello again,

Could you please describe your use case? Perhaps you need to implement a plugin for TeamCity, instead of using REST API. Please note that there are several Cloud plugins available for TeamCity.


Hi Alina,

My use case is to auto scale a bunch of build hosts.  We have times when we're really busy and needs lots of hosts and times when nothing is happening.  Basically I need to know how many builds of a certain template type are in the queue and I need to know which agents of a certain name are running builds.  That way I can add/remove hosts as they are needed.

I am also coming up against an issue where my REST call will randomly never return.  It'll just sit there waiting forever, do you have any idea why?


I did go look at the Cloud Plugins but I'm not sure the AWS one would work for us as we don't want to be terminating/creating instances, only start/stop them.  I have a script that is working for this currently, I was just trying to optimize my TC REST calls.


Hello Anne,

It seems that the cloud agent integration is the feature that is suitable in your case. TeamCity will leverage clouds elasticity to provision additional build agents on-demand. You can use Amazon EC2 cloud plugin. If an EBS-based instance id is specified in the images list, the instance is stopped (not terminated). Please try this plugin on.


Please sign in to leave a comment.