Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity REST API get list of pending changes

Is there a REST API endpoint to get a collection of changes that are pending for a build in TeamCity?

We have the build set to manual and it is triggered outside TeamCity and would like to show a bullet point list of commits that'd be in that build.

In the user interface you can see this under the "Pending Changes (X)" tab.

I can't find any examples of doing this and the closest I've found is:

http://<server>/httpAuth/app/rest/changes/buildType:<build type id>

This seems to return the last change though.

Anyone done this before?

like image 444
Phil Avatar asked Feb 10 '14 09:02

Phil


2 Answers

I just found a working solution thanks to this question. I'll show it here in case other people are looking for a full solution :

You need to know the buildTypeId of the build on which you want to get the pending changes. In this case lets say buildTypeId=bt85

1
    http://<server>/httpAuth/app/rest/buildTypes/id:bt85/builds/
    // Get the last build from the XML returned.
    // Lets say last build id = 14000

2

    http://<server>/httpAuth/app/rest/changes?build=id:14000
    // The newest change returned is the one you need.
    // Lets say newest change id = 15000

3

    http://<server>/httpAuth/app/rest/changes?buildType=id:bt85&sinceChange=15000
    // You're now looking at the pending changes list of the buildType bt85
like image 82
EoiFirst Avatar answered Oct 25 '22 03:10

EoiFirst


My eventual solution in a work around kind of way is to:

Find the latest change ID from my database of builds outside of TeamCity (I guess you could query the TeamCity API to find the last successful build and pull it from there)

Then call:

http://<server>/httpAuth/app/rest/changes?buildId=id:<build id>&sinceChange=id:<last change id>

Then fetch each individual change from that list.

A bit of a workaround but I couldn't see anyway otherwise to get the list of pending changes.

like image 43
Phil Avatar answered Oct 25 '22 05:10

Phil