3
votes

Is it possible to cancel a currently running build via REST API?

I've got an integration which fetches currently running builds, and I would like to terminate builds of a given type if they are failed. I know how to list the failing builds of a given type, how do I then pass the stop command?

3

3 Answers

3
votes

Since TeamCity 8.1 it is possible to stop build using REST API:

curl -v -u user:password --request POST "http://localhost:7000/app/rest/buildQueue/<buildLocator>" --data "<buildCancelRequest comment='' readdIntoQueue='true' />" --header "Content-Type: application/xml"
2
votes

Maybe not with the REST API, but if you look here (towards the bottom in the Comments section) there's an 'undocumented' feature that lets you do it over HTTP.

1
votes

Not exactly the REST call you were looking for, but you can simply do an HTTP POST to:

http://teamcity.my.org/viewLog.html?buildTypeId=bt278&buildId=1352480#

Where:

  • buildTypeId is your project's id

  • buildId is the build number to stop

Obviously, you can only do this while the build is running.