API: cancelling running builds

Answered

I'm trying to cancel a running build via the API. When I POST, as instructed by the docs, I get a 405 response with this content:

Error has occurred during request processing (405).\nError: javax.ws.rs.WebApplicationException\nNot supported request. Please check URL, HTTP method and transfered data are correct. metadata: [Allow:[GET,DELETE,OPTIONS,HEAD],]

This tells me that POST is not supported. And the build is not cancelled.

Since I saw DELETE in the list of supported methods, I tried that. DELETE does cancel the build, but returns a 400 with this message:

Error has occurred during request processing (Bad Request).\nError: jetbrains.buildServer.server.rest.errors.BadRequestException: Deleting not finished builds is not supported. Cancel the build and only then delete it.\nInvalid request. Please check the request URL and data are correct.

Am I doing it wrong?

 

4 comments

Hello,

Could you please post the example of the POST request that you used?

0

I reworked it as a curl using the example from the docs:

>>> curl -v -u "robot:<pass>" --request POST "http://<host>:8111/app/rest/builds?locator=id:8962" --data "<buildCancelRequest comment='' readdIntoQueue='false' />" --header "Content-Type: application/xml"
...
>
* upload completely sent off: 56 out of 56 bytes
< HTTP/1.1 405 Method Not Allowed
< Server: Apache-Coyote/1.1
< Set-Cookie: TCSESSIONID=79BFB69ED33B151551CC8B9391D25D5E; Path=/; HttpOnly
< Set-Cookie: RememberMe=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly
< Pragma: no-cache
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Cache-Control: no-cache
< Cache-Control: no-store
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Date: Thu, 28 Apr 2016 13:51:55 GMT
<
Error has occurred during request processing (405).
Error: javax.ws.rs.WebApplicationException
* Connection #0 to host e0264.test.urbanairship.com left intact
Not supported request. Please check URL, HTTP method and transfered data are correct. metadata: [Allow:[GET,DELETE,OPTIONS,HEAD],]%

 

0

The URL with "?locator" returns the list of builds. POST requests are only supported for a specific build, for example:

http://<host>:8111/app/rest/builds/id:8962
0

That worked! I could have sworn I tried that, but I must have messed it up some other way. Thank you!

0

Please sign in to leave a comment.