How do I get the vcs changes since last successful build?

I'm trying to get the same results from the REST api as I would from the UI:

Currently, I just get the changes for newest build (https://teamcity.local/httpAuth/app/rest/changes?build=id:1234), but I'd like to get all the changes since the last time the build was successful.

Is there a single api call to do this? Or what's the simplest way?


Comment actions Permalink


An obvious approach is to get the id of the last change in a "since" build you want to use and then issue a request like
If you know the "since" build id you can even use

There is no one request way to find a previous failed build, though. You can get the build's sequence and find the necessary build.

Note: I will look into adding ability to find previous failed build in one request in the future TeamCity versions.

Comment actions Permalink

Yet another possible approach:

Since TeamCity 9.0 you can get the list of builds with the change details right away via a request like:

Comment actions Permalink

Hi, thanks for replying.

The problem is that there's no good way of knowing the 'sinceChange' id.
It means I have to first query all the builds for the specific build types and determine whether they were successful or not, then run an additional query to get the changes id for the last successful build.
Only then would I be able to run .../app/rest/changes?locator=buildType:(id:XXX),sinceChange:(id:YYY)
It's pretty big overhead to run so many api calls for the off chance a build might fail.

Is there a faster way to do this I'm not thinking of?

Comment actions Permalink


Looking into this more: it seems that it is actually possible to get changes since "last successful" build till the current moment in a single request.

Basically the request
should give you the previous failed build (before the build with id ZZZ).
gives you all the changes since that build.

Still, my second suggestion to get list of builds with the changes included might be better: you just need to iterate through the builds and the changes are already there.

Comment actions Permalink

I also would like to get all the changes since last successful build.

I'm using TC version 9.x and the following api calls that were recommended here didn't work for me.



In fact the only way I was able to use 'sinceChange' was by 'change id'. Is there a way to apply 'sinceChange' using build id?


Many thanks


Please sign in to leave a comment.