3

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?

Abraham P
  • 15,029
  • 13
  • 58
  • 126

3 Answers3

3

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"
Graham
  • 1,529
  • 16
  • 22
Alina Mishina
  • 3,320
  • 2
  • 22
  • 31
  • Updated version documented here https://www.jetbrains.com/help/teamcity/rest-api.html#RESTAPI-BuildCanceling/Stopping but largely the same – ojintoad Feb 26 '20 at 20:00
2

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.

mattyB
  • 1,094
  • 10
  • 21
1

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.

carlspring
  • 31,231
  • 29
  • 115
  • 197