Cancel a build
You can use the Build Management API to cancel a build that is in progress or to remove a build from the queue. Once the build is completed, you can't cancel this build.
All sample requests in this guide include the following path parameters:
| Parameter name | Description |
|---|---|
tenantId | Tenant ID. |
starId | ID of a star. |
buildId | Unique identifier within the CI/CD server instance that is automatically assigned to each build. |
To cancel the build, you need to have the build ID. You can get the build ID in one of the following ways:
- By checking a list of available builds.
- From the response, after running a build.
To cancel the build, send the following POST request:
curl -X 'POST' \
'{baseURL}/api/v1/tenants/{tenantId}/stars/{starId}/builds/{buildId}/cancel' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {access_token}' \
-d '{body}'
In the request {body}, you can provide a reason for the build cancellation. For example:
{
"comment": "Canceling because of an incorrect parameter."
}
A response contains a JSON object with the canceled build information and the cancellation details:
{
"id": 1,
"application": {
"name": "ContactManager",
"type": "ContactManager"
},
"buildType": "IS_Build",
"number": 1,
"status": "CANCELED",
"statusMessage": "Canceled (Step 5/8)",
"branch": "main",
"queuedDate": "2024-12-02T13:39:41Z",
"startDate": "2024-12-02T13:43:41Z",
"finishDate": "2024-12-02T13:48:35Z",
"triggered": {
"type": "user",
"username": "jdoe",
"date": "2024-12-02T13:39:41Z"
},
"comment": "Build Execution for feature smoke testing.",
"revisions": [
{
"vcsBranchName": "main",
"version": "b136fe9c9e4a5242c59cb2ea846e4ba28c94759e"
}
],
"statistics": {
"queuedDurationMillis": 185,
"buildDurationMillis": 3250
},
"tags": ["e2e-test"],
"cancellationInfo": {
"username": "jdoe",
"comment": "Build cancelled from build-management-service | Canceling because of an incorrect parameter."
}
}
After cancelling the build, the following comment is automatically added to the response: Build cancelled from build-management-service. If you provided your comment in the request body, it will be added after the automatic comment from Build Management.