Get lastFinished build (across all build types) via REST?

Is anyone aware of an efficient way to get the id of the most recently finished build - without regard to build type - via REST? I have an external script that does incremental backups of new artifacts and build logs, and one of the things it does when it starts is capture the lowest-numbered build currently running; at the end of a successful incremental backup, the value captured at the start of the run is saved, so it can be used as a starting point for looking for new artifacts and build logs during the next run.

This works well when there are actually builds running (i.e. most of the time). However, there are occasionally times when there are no builds running; at those times, the logical thing to do would be to grab the ID of the last finished build when the backup starts, and save that at the end of the backup run. But I can't find a way to do this efficiently via the REST API. I've tried a few different approaches, but they either run slowly (e.g. retrieving the list of build types - hundreds of them, in this case - then iterating over them, and getting the last build from each) or they cause TeamCity to grind to a halt with OutOfMemory errors (e.g. app/rest/builds/?count=1).

Any ideas?



1 comment
Comment actions Permalink

Hi Nicholas,

Sorry for the delay in replying.

> or they cause TeamCity to grind to a halt with OutOfMemory errors (e.g. app/rest/builds/?count=1)

Actually,  app/rest/builds/?count=1 should work fine and it does in my environment.
Could you provide more data on the OutOfMemory? Is it reproducible?

If you are on 7.0, you can use app/rest/builds/count:1,lookupLimit:N which will process only N builds. However, if none of the latest N builds match other specified criteria of the build locator, you will get 404 response.


Please sign in to leave a comment.