TeamCity Rest API – Run Custom Build

teamcity

I am trying to trigger a custom build on a project passing in a specific modificationId as mentioned here.

e.g httpAuth/action.html?add2Queue=bt27&modificationId=3605

This works great. However I need to be able to get the modificationId of the last know successful build. I cannot see or find any mention of this in the rest api docs.

I am able to retrieve the buildId of the last successful build but the modificationId is
not included

e.g httpAuth/app/rest/buildTypes/id:bt27/builds/status:SUCCESS/number

Does anybody know how to get a list of modificationIds from the rest api?

Best Answer

You can get all the builds for a particular project or build config like this:

http://yourserver/app/rest/buildTypes/id:your_project_id

You can filter these results to only show the most recent successful build like this:

http://yourserver/app/rest/buildTypes/id:your_project_id/?count=1&status=SUCCESS

Use a script to load the href from the build returned by the above url and you can get the "lastChanges" element, which always contains the ID of the last change.

You can then send the link below to trigger a build that will only include changes up to that ID like this:

http://yourserver/app/rest/action.html?add2Queue=your_project_id&modificationId=000000

NOTE: The ID attribute in the lastChanges element is the one you want to use as the modificationID. This is not the actual change ID from your VCS though. This is an internal Team City ID.

Related Topic