7
votes

I am trying to figure out a way of returning all the last finished builds from teamcity. Essentially I am creating a status page for teamcity and want to show all the currently failing builds. So far I have tried various API calls. The following API call I thought for sure would give me all failures since the last successful builds, but it doesn't seem to work.

/guestAuth/app/rest/builds/?locator=status:failure,sinceBuild:(status:success)

Any help would be greatly appriciated. If I can get all the last finished builds, I can just sort to show only failures.

2

2 Answers

2
votes

That REST call is correct. I am using TeamCity 7.1. Could it be that you simply haven't had any failures since the last successful build? Try inverting the conditions:

/guestAuth/app/rest/builds/?locator=status:success,sinceBuild:(status:failure)

This will return a list of successful builds since the last failure (the opposite). If you get results with this query, then your query should return no results. In otherwords, of these two queries:

/guestAuth/app/rest/builds/?locator=status:failure,sinceBuild:(status:success) /guestAuth/app/rest/builds/?locator=status:success,sinceBuild:(status:failure)

At any given time, given that there are completed builds, one should ALWAYS return zero builds and the other should ALWAYS return one or more builds.

2
votes

According to a comment on this JetBrains' ticket, since TeamCity 8.1 it is possible to use this API call to get the latest build status for all build configurations under a project:

http://teamcity.jetbrains.com/app/rest/buildTypes?locator=affectedProject:(id:TeamCityPluginsByJetBrains)&fields=buildType(id,name,builds($locator(running:false,canceled:false,count:1),build(number,status,statusText)))