7
votes

I am using TeamCity 7.1. I want to get a list including the last build of each build configuration (build type) that is currently not running. I found this question: TeamCity - How do you get a list of the last finished build of each project through rest api? but the REST URI in the answer did not work for me.

<teamcity-server>/httpAuth/app/rest/builds?locator=sinceBuild:(status:failure) 

seems to work and gives me all builds that succeeded after failing before.

But the opposite

<teamcity-server>/httpAuth/app/rest/builds?locator=sinceBuild:(status:success)

does not return any builds.

I know that I can get all build types, iterate though them and get the most recent finished build using

<teamcity-server>/httpAuth/app/rest/buildTypes/id:<build-type-id>/builds/running:false?count=1&start=0 

("count=1&start=0" may not be necessary) but I am not really sure that what I get is really the latest build. Also this requires many REST calls for all build types. A neat solution would use only one REST call.

Any ideas?

1
I tried, both <teamcity-server>/httpAuth/app/rest/builds?locator=sinceBuild:(status:failure) and <teamcity-server>/httpAuth/app/rest/builds?locator=sinceBuild:(status:success) and those are working. The second might not be working for you since you may not be having any builds after the last successful build. Then it will return 0 count. By and large at a time either of them will give you a 0 count because your last build will either be a SUCCESS or a FAILURE.RinoTom

1 Answers

5
votes

As per the TeamCity REST API documentation from JetBrains, the builds can be located either of the following ways:

<teamcity-server>/httpAuth/app/rest/buildTypes/id:<build-type-id>/builds/running:false,status:success

OR

<teamcity-server>/httpAuth/app/rest/builds/running:false,status:success

This is must to have the buildType is being suffixed by a <buildTypeLocator> as per the current REST API if you are trying to query something under the buildType and <buildTypeLocator> can be id:<btXXX_internal_buildConfiguration_id> or name:<Build_Configuration_name> (Quote from documentation). So it is must that you need to specify build id or build name.

But, the ideal way as you expected will be something like:

<teamcity-server>/httpAuth/app/rest/buildTypes/builds/running:false,status:success

Probably, you can raise this up in TeamCity Support I suppose.