finding the most recent svn revision built by team city

Hey guys,

we have a teamcity server that continuously builds the latest svn revision. Im currently working on another service that requires the most recent svn revision built by teamcity. I want to talk to teamcity through http. So I use something like the following to get a list of recent builds (side question: is there a limit to the size of this list?)

http:// *** /httpAuth/app/rest/buildTypes/id: *** /builds?status=SUCCESS

This returns an xml document containing info on the recent builds and I can grab the first node to get the most recent build and most of the time this will be the most recent svn revision, however I suspect sometimes the most recent build might be produced with an outdated svn revision.

Can anyone comment on a reliable way to get the build id for the build that was created witht the most recent svn revision? My current plan is going through the list returned by the url above, and use the following to determine the svn revision for each build.

http:// *** /httpAuth/app/rest/builds/id: ***

As the first xml doc grows it seems that this approach might take some time and causes a lot of http calls. Is there a better way? Perhaps we should set up a build type which guarantees that the latest build was built with the most recent svn revision, but I am hoping to avoid that.

Thanks, Bas

1 comment
Comment actions Permalink


> side question: is there a limit to the size of this list?

By default, the request you mentioned returns 100 last builds. You can change that by adding "&count=N" to the URL where N is the count of the items to return. There is also zero-based "start" parameter that can be used to serve items beginning from the specified number.

> I suspect sometimes the most recent build might be produced with an outdated svn revision.

This is right, usually the builds are served ordered by their id (effectively by their start order). In case revision of the build is fixed (either in custom run dialog or with the help of snapshot dependencies or quiet period), the "by changes" order of the builds may differ.

To get whether the build is breaking the changes sequence, you can lookup "history" attribute of the build details. You will probably be interested in history="false" builds. As usually the builds start sequence is the same as ordered by changes sequence, this is unlikely that you will need to check many builds before you find the one with most recent changes.

We can probably add ability to serve the builds in the order of changes and not start order. Feel free to file a feature request.

In versions 5.0.x there is a side-effect, that you may use: if you specify "sinceBuild" parameter, for the "builds" request, the builds will be returned ordered by changes and not start time. However, this behavior is not documented yet and in theory can change in the future versions.
If you choose to use this approach, you can use request like:
http://*** /httpAuth/app/rest/buildTypes/id: *** /builds?status=SUCCESS&sinceBuild=id:<last_used_build_id>&count=1

Hope this helps.


Please sign in to leave a comment.