API: Locating a running build by the agent building it

Answered

If I know the id of an agent, I'd like to be able to use the API and a locator to find the build running on that agent if one is running. Is this possible or do I need to iterate over the list of all builds?

Thanks,
Jasen

4 comments

Hi Jasen,

Please use the following request:

http://teamcity:8111/app/rest/builds?locator=agentName:<agentName>,running:true
1

Thanks, Alina.

 

I can get a list of builds by omitting the "running:true" clause, but I always get a 0-count list -- even with agents I can see are working on a build -- using it.

My results look like this using "running:true":

<builds count="0" href="/app/rest/builds?locator=agentName:<agentName>,running:true"/>

where <agentName> is a legitimate name for an agent.

Has this feature been deprecated since this was posted?

0

Nevermind. It looks like it's possible to get the current build with a request like this:

https://teamcity:8111/httpAuth/app/rest/builds?locator=running:true,agentName:<Valid Agent Name>,branch:

It's the branch bit at the end that appears to make it work.

0

Hello Jasen,

By default only builds from the default branch are returned. To retrieve all builds, the following locator should be used:

branch:default:any
0

Please sign in to leave a comment.