资源组 API
您可以阅读更多关于使用资源组控制作业并发的内容。
获取一个项目内所有的资源组
GET /projects/:id/resource_groups
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| integer/string | yes | 认证用户拥有的 ID 或url 编码的项目路径 |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/resource_groups"
响应示例:
[
{
"id": 3,
"key": "production",
"process_mode": "unordered",
"created_at": "2021-09-01T08:04:59.650Z",
"updated_at": "2021-09-01T08:04:59.650Z"
}
]
获取特定的资源组
GET /projects/:id/resource_groups/:key
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| integer/string | yes | 认证用户拥有的 ID 或url 编码的项目路径 |
key
| string | yes | 资源组的键值 |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/resource_groups/production"
响应示例:
{
"id": 3,
"key": "production",
"process_mode": "unordered",
"created_at": "2021-09-01T08:04:59.650Z",
"updated_at": "2021-09-01T08:04:59.650Z"
}
编辑现有的资源组
更新现有资源组的属性。
如果资源组成功更新,则返回的状态码为 200
。如果出现错误,则返回的状态代码为 400
。
PUT /projects/:id/resource_groups/:key
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| integer/string | yes | 认证用户拥有的 ID 或url 编码的项目路径 |
key
| string | yes | 资源组的键值 |
process_mode
| string | no | 资源组的进程模式:unordered 、 oldest_first 或 newest_first 。请阅读进程模式获取更多信息
|
curl --request PUT --data "process_mode=oldest_first" \
--header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/resource_groups/production"
响应示例:
{
"id": 3,
"key": "production",
"process_mode": "oldest_first",
"created_at": "2021-09-01T08:04:59.650Z",
"updated_at": "2021-09-01T08:13:38.679Z"
}