Help us learn about your current experience with the documentation. Take the survey.
冻结期 API
- 版本:Free, Premium, Ultimate
- 产品:GitLab.com, GitLab Self-Managed, GitLab Dedicated
使用此 API 来管理部署冻结期。
权限与安全
拥有 Reporter 权限 或更高级别的用户可以读取冻结期 API 端点。只有拥有 Maintainer 角色的用户才能修改冻结期。
列出所有冻结期
获取冻结期的分页列表,按 created_at 升序排列。
GET /projects/:id/freeze_periods| 属性 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
id |
整数/字符串 | 是 | 项目的 ID 或 URL 编码路径。 |
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/19/freeze_periods"示例响应:
[
{
"id":1,
"freeze_start":"0 23 * * 5",
"freeze_end":"0 8 * * 1",
"cron_timezone":"UTC",
"created_at":"2020-05-15T17:03:35.702Z",
"updated_at":"2020-05-15T17:06:41.566Z"
}
]获取单个冻结期
获取指定 freeze_period_id 的冻结期。
GET /projects/:id/freeze_periods/:freeze_period_id| 属性 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
id |
整数或字符串 | 是 | 项目的 ID 或 URL 编码路径。 |
freeze_period_id |
整数 | 是 | 冻结期的 ID。 |
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/19/freeze_periods/1"示例响应:
{
"id":1,
"freeze_start":"0 23 * * 5",
"freeze_end":"0 8 * * 1",
"cron_timezone":"UTC",
"created_at":"2020-05-15T17:03:35.702Z",
"updated_at":"2020-05-15T17:06:41.566Z"
}创建冻结期
创建一个冻结期。
POST /projects/:id/freeze_periods| 属性 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
id |
整数或字符串 | 是 | 项目的 ID 或 URL 编码路径。 |
freeze_start |
字符串 | 是 | 冻结期的开始时间,使用 cron 格式。 |
freeze_end |
字符串 | 是 | 冻结期的结束时间,使用 cron 格式。 |
cron_timezone |
字符串 | 否 | cron 字段的时区,如果未提供,则默认为 UTC。 |
示例请求:
curl --header 'Content-Type: application/json' --header "PRIVATE-TOKEN: <your_access_token>" \
--data '{ "freeze_start": "0 23 * * 5", "freeze_end": "0 7 * * 1", "cron_timezone": "UTC" }' \
--request POST "https://gitlab.example.com/api/v4/projects/19/freeze_periods"示例响应:
{
"id":1,
"freeze_start":"0 23 * * 5",
"freeze_end":"0 7 * * 1",
"cron_timezone":"UTC",
"created_at":"2020-05-15T17:03:35.702Z",
"updated_at":"2020-05-15T17:03:35.702Z"
}更新冻结期
更新指定 freeze_period_id 的冻结期。
PUT /projects/:id/freeze_periods/:freeze_period_id| 属性 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
id |
整数或字符串 | 是 | 项目的 ID 或 URL 编码路径。 |
freeze_period_id |
整数 | 是 | 冻结期的 ID。 |
freeze_start |
字符串 | 否 | 冻结期的开始时间,使用 cron 格式。 |
freeze_end |
字符串 | 否 | 冻结期的结束时间,使用 cron 格式。 |
cron_timezone |
字符串 | 否 | cron 字段的时区。 |
示例请求:
curl --header 'Content-Type: application/json' --header "PRIVATE-TOKEN: <your_access_token>" \
--data '{ "freeze_end": "0 8 * * 1" }' \
--request PUT "https://gitlab.example.com/api/v4/projects/19/freeze_periods/1"示例响应:
{
"id":1,
"freeze_start":"0 23 * * 5",
"freeze_end":"0 8 * * 1",
"cron_timezone":"UTC",
"created_at":"2020-05-15T17:03:35.702Z",
"updated_at":"2020-05-15T17:06:41.566Z"
}删除冻结期
删除指定 freeze_period_id 的冻结期。
DELETE /projects/:id/freeze_periods/:freeze_period_id| 属性 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
id |
整数或字符串 | 是 | 项目的 ID 或 URL 编码路径。 |
freeze_period_id |
整数 | 是 | 冻结期的 ID。 |
示例请求:
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/19/freeze_periods/1"