API locator to retrieve all completed builds since last called

In the REST API "builds" method, is there a locator I can use to get all of the builds _completed_ since the last time I asked?

To feed build data (success/fail, duration, etc.) into our monitoring service (DataDog) I'd like to regularly query data on all completed builds.  I had been using a locater of "sinceBuild:id:XXXXXX" where XXXXXX is the highest build id last processed.


<builds count="4" href="/guestAuth/app/rest/builds?locator=sinceBuild:id:301854,branch:unspecified:any">
  <build id="301861" buildTypeId="aipkit_Ta_AutoL3Develop_BasicHw" number="9" status="FAILURE" state="finished" branchName="refs/heads/master" defaultBranch="true" href="/guestAuth/app/rest/builds/id:301861" webUrl="http://teamcity/viewLog.html?buildId=301861&amp;buildTypeId=aipkit_Ta_AutoL3Develop_BasicHw"/>
  <build id="301859" buildTypeId="aipkit_Ta_AutoL3Develop_BasicSi" number="68" status="FAILURE" state="finished" branchName="refs/heads/master" defaultBranch="true" href="/guestAuth/app/rest/builds/id:301859" webUrl="http://teamcity/viewLog.html?buildId=301859&amp;buildTypeId=aipkit_Ta_AutoL3Develop_BasicSi"/>
  <build id="301857" buildTypeId="aipkit_package_Develop" number="226" status="SUCCESS" state="finished" branchName="develop" defaultBranch="true" href="/guestAuth/app/rest/builds/id:301857" webUrl="http://teamcity/viewLog.html?buildId=301857&amp;buildTypeId=aipkit_package_Develop"/>
  <build id="301856" buildTypeId="aipkit_Ta_AutoL3Develop_BasicHw" number="8" status="SUCCESS" state="finished" branchName="refs/heads/master" defaultBranch="true" href="/guestAuth/app/rest/builds/id:301856" webUrl="http://teamcity/viewLog.html?buildId=301856&amp;buildTypeId=aipkit_Ta_AutoL3Develop_BasicHw"/>

But this doesn't work properly as the id is assigned at start of job, and with this logic I only get a sampling of the faster builds, the slower ones never get loaded.

I considered using a locater of "sinceDate:XXXXXXXXTXXXXXX+XXXX" but, again, the timestamp is from when the build started, so it is really no more useful than using build id.

It looks like I may be able to specify "running:any" to get a list of all builds currently running, so i could re-query a list of builds that I know to be still running. But this adds to the number of queries I have to make to TeamCity, the amount of state I have to save, or both.

I've read the documentation and searched the forums, so apologies if I am re-asking something obvious.  I would be grateful for any tips/approaches to using a locator I can use get the list of builds that have completed since the last time it was called?

Kind Regards,


Comment actions Permalink

Hi David,

Currently it is not possible to get what you want using one REST API request. Please vote for the related feature request in our tracker: https://youtrack.jetbrains.com/issue/TW-18098.
As current workaround you can use the approach that you suggested or create a script to filter out builds with "finishDate" less than the date of the last call.

Comment actions Permalink

Well, thanks for a definitive answer. Will look into alternatives.

Have voted the issue up.  Have checked out the code, it shouldn't be difficult to add a "sinceFinishedBuild" or "SinceFinishedDate" query to the code.  I may experiment with that, but would worry that the underlying TeamCity indexes may not respond well to it.

Perhaps I can turn this around and add a "notify monitoring" step to all of our builds.

Is there a way to add a command, essentially a hidden build step, to all of the builds on our TeamCity system?
Ideally (for me) it would be to run a command like, say, "notifyDataDog.py <buildid>" which would then query the build status, data, statistics, etc. and upload them.

Best Regards,


Comment actions Permalink

There is no built-in feature for it. Please vote for the related request: https://youtrack.jetbrains.com/issue/TW-38259.
As for now you can create a new build configuration with finish build triggers for all needed build configurations.
Another approach is to create a plugin. Please find more details in this comment.


Please sign in to leave a comment.