Abraham P
Abraham P

Reputation: 15471

Stop a TeamCity build via REST call

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?

Upvotes: 3

Views: 2160

Answers (3)

Alina Mishina
Alina Mishina

Reputation: 3370

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"

Upvotes: 3

carlspring
carlspring

Reputation: 32567

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.

Upvotes: 1

mattyB
mattyB

Reputation: 1104

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.

Upvotes: 2

Related Questions