Rest – TeamCity – How to get a list of the last finished build of each project through rest api

apirestteamcity

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.

Best Answer

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.

Related Topic