
# 取消构建任务
#### 功能介绍
此API用于根据构建任务实例ID取消构建任务。
#### URI
PATCH /assembling/v1/builds/{build_id}
表1路径参数 
| 参数       | 是否必选 | 参数类型   | 描述                                                                                                                 |
|:---|:---|:---|:---|
| build_id | 是    | String | 构建任务实例ID。获取方法，请参考[根据构建任务ID获取构建任务实例列表](https://support.huaweicloud.com/api-servicestage/servicestage_06_0219.html)。 |
   
#### 请求消息
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                           |
|:---|:---|:---|:---|
| Content-Type | 是    | String | 消息体的类型（格式），默认取值为"application/json;charset=utf8"。                                                                                             |
| X-Auth-Token | 是    | String | 调用接口的认证方式分为Token和AK/SK两种，如果您使用的Token方式，此参数为必填，请填写Token的值。Token获取方式，请参考[获取用户Token](https://support.huaweicloud.com/api-iam/iam_30_0001.html)。 |
   
#### 响应消息
表3响应参数 
| 参数                    | 参数类型    | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
|:---|:---|:---|
| build_id              | String  | 构建ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| job_id                | String  | 任务ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| job_name              | String  | 任务名称。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| enterprise_project_id | String  | 企业项目ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| index                 | Integer | 构建在其任务下的索引号。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| started_at            | String  | 创建时间。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ended_at              | String  | 结束时间。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| build_state           | String  | 状态。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| repo_type             | String  | 代码仓类型。 - DevCloud，codearts制品仓。  - Gitee，开源中国推出代码托管平台。    - GitHub，开源代码仓。  - GitLab，开源代码仓。  - Bitbucket，源代码托管网站。   |
| repo_endpoint         | String  | 仓库接入地址。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| repo_web_url          | String  | 仓库的web访问地址。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| repo                  | String  | 具体仓库地址。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| branch                | String  | 代码分支。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| commit_id             | String  | 代码提交ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| committer             | String  | 代码提交者。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| commit_time           | String  | 代码提交时间。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| commit_comment        | String  | 代码提交评论。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| language              | String  | 软件构建语言。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| swr_repository        | String  | 软件/镜像归档后的访问地址。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| swr_repo_page         | String  | 镜像访问url。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| archive_result        | Object  | 归档详细信息。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| base_image            | String  | 构建指定的基础镜像。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| seccomp_path          | String  | 挂载相对路径。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| type                  | String  | 构建类型 - auto：自动触发  - user：手动触发                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| creator               | String  | 构建创建人。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| code_repo_anatomy     | Object  | 代码仓库的详细形式，请参考[表4 代码仓库参数]。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| os                    | Object  | 构建使用的系统信息。请参考[表5 OS参数]。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
   
 表4代码仓库参数 
| 参数         | 参数类型   | 描述        |
|:---|:---|:---|
| name       | String | 仓库名称。     |
| archiveURL | String | 二进制包下载地址。 |
   
 表5OS参数 
| 参数   | 参数类型   | 描述    |
|:---|:---|:---|
| arch | String | 架构信息。 |
   
#### 请求示例
无
#### 响应示例
```
{
  "build_id": "kzqjkrvbglqbczhm82kkjlh0ixe2o2wv8v85fpmv",
  "job_id": "qexh8qwfmuvlv1y078delx51vn0tsjsmsb23e0e0",
  "job_name": "",
  "enterprise_project_id": "",
  "index": 4,
  "started_at": "2025-11-14 08:00:42 +0000 UTC",
  "ended_at": "2025-11-14 08:00:54 +0000 UTC",
  "build_state": "Cancel",
  "repo_type": "BinObs",
  "repo_endpoint": "",
  "repo_web_url": "",
  "repo": "obs://demo/MainLoop.jar",
  "branch": "",
  "commit_id": "",
  "committer": "",
  "commit_time": "",
  "commit_comment": "",
  "language": "java",
  "swr_repository": {
    "1754123329469": "test.com/test/test-0802-1:afdafds"
  },
  "swr_repo_page": {
    "1754123329469": "https://test.com/dockyard/v2/domains/paas_servicestage_test/namespaces/test/repositories?repository=test-0802-1&is_public=false&description=&category=other"
  },
  "archive_result": {},
  "base_image": "",
  "seccomp_path": "",
  "type": "user",
  "creator": "paas_servicestage_test",
  "code_repo_anatomy": null,
  "os": {
    "arch": "x86_64"
  }
}
```
#### 状态码
| 状态码 | 描述     |
|:---|:---|
| 200 | 操作成功。  |
| 400 | 错误的请求。 |
   
#### 错误码
请参考[ServiceStage错误码](https://support.huaweicloud.com/api-servicestage/servicestage_06_0162.html)。
