Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity - How do you get a list of the last finished build of each project through rest api?

Tags:

rest

teamcity

api

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.

like image 586
user1224047 Avatar asked Jun 18 '12 19:06

user1224047


2 Answers

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.

like image 128
Nick Williams Avatar answered Oct 03 '22 20:10

Nick Williams


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)))
like image 29
Techromancer Avatar answered Oct 03 '22 20:10

Techromancer