- 获取所有流水线调度
- 获取单个流水线调度
- 获取由流水线调度触发的所有流水线
- 创建新的流水线调度
- 编辑流水线调度
- 获取流水线调度的所有权
- 删除流水线调度
- 立即运行已调度的流水线
- 流水线调度变量
- 创建新的流水线调度变量
- 编辑流水线调度变量
- 删除流水线调度变量
{{< details >}}
- Tier: 基础版, 专业版, 旗舰版
- Offering: JihuLab.com, 私有化部署
{{< /details >}}
你可以阅读更多关于流水线调度的信息。
获取所有流水线调度
获取一个项目的流水线调度列表。
GET /projects/:id/pipeline_schedules
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | Yes | 项目的 ID 或URL 编码路径 |
scope |
string | No | 流水线调度的范围,必须是其中之一:active , inactive
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules"
[
{
"id": 13,
"description": "Test schedule pipeline",
"ref": "refs/heads/main",
"cron": "* * * * *",
"cron_timezone": "Asia/Tokyo",
"next_run_at": "2017-05-19T13:41:00.000Z",
"active": true,
"created_at": "2017-05-19T13:31:08.849Z",
"updated_at": "2017-05-19T13:40:17.727Z",
"owner": {
"name": "Administrator",
"username": "root",
"id": 1,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "https://gitlab.example.com/root"
}
}
]
获取单个流水线调度
获取一个项目的流水线调度。
GET /projects/:id/pipeline_schedules/:pipeline_schedule_id
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | Yes | 项目的 ID 或URL 编码路径 |
pipeline_schedule_id |
integer | Yes | 流水线调度 ID |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13"
{
"id": 13,
"description": "Test schedule pipeline",
"ref": "refs/heads/main",
"cron": "* * * * *",
"cron_timezone": "Asia/Tokyo",
"next_run_at": "2017-05-19T13:41:00.000Z",
"active": true,
"created_at": "2017-05-19T13:31:08.849Z",
"updated_at": "2017-05-19T13:40:17.727Z",
"last_pipeline": {
"id": 332,
"sha": "0e788619d0b5ec17388dffb973ecd505946156db",
"ref": "refs/heads/main",
"status": "pending"
},
"owner": {
"name": "Administrator",
"username": "root",
"id": 1,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "https://gitlab.example.com/root"
},
"variables": [
{
"key": "TEST_VARIABLE_1",
"variable_type": "env_var",
"value": "TEST_1",
"raw": false
}
]
}
获取由流水线调度触发的所有流水线
获取项目中由流水线调度触发的所有流水线。
GET /projects/:id/pipeline_schedules/:pipeline_schedule_id/pipelines
支持的属性:
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | Yes | 项目的 ID 或URL 编码路径 |
pipeline_schedule_id |
integer | Yes | 流水线调度 ID |
示例请求:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/pipelines"
示例响应:
[
{
"id": 47,
"iid": 12,
"project_id": 29,
"status": "pending",
"source": "scheduled",
"ref": "new-pipeline",
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
"web_url": "https://example.com/foo/bar/pipelines/47",
"created_at": "2016-08-11T11:28:34.085Z",
"updated_at": "2016-08-11T11:32:35.169Z"
},
{
"id": 48,
"iid": 13,
"project_id": 29,
"status": "pending",
"source": "scheduled",
"ref": "new-pipeline",
"sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a",
"web_url": "https://example.com/foo/bar/pipelines/48",
"created_at": "2016-08-12T10:06:04.561Z",
"updated_at": "2016-08-12T10:09:56.223Z"
}
]
创建新的流水线调度
创建一个项目的新流水线调度。
POST /projects/:id/pipeline_schedules
Attribute | Type | Required | Description |
---|---|---|---|
cron |
string | Yes | cron 调度,例如:0 1 * * * 。 |
description |
string | Yes | 流水线调度的描述。 |
id |
integer/string | Yes | 项目的 ID 或URL 编码路径 |
ref |
string | Yes | 被触发的分支或标签名称。短版本(例如 main )和完整版本(例如 refs/heads/main 或 refs/tags/main )都可以接受。如果提供了短版本,它会自动扩展为完整版本,但如果 ref 是模糊的,则会被拒绝。 |
active |
boolean | No | 流水线调度的激活状态。如果设置为 false,流水线调度最初是未激活的(默认:true )。 |
cron_timezone |
string | No |
ActiveSupport::TimeZone 支持的时区,例如:Pacific Time (US & Canada) (默认:UTC )。 |
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
--form description="Build packages" --form ref="main" --form cron="0 1 * * 5" --form cron_timezone="UTC" \
--form active="true" "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules"
{
"id": 14,
"description": "Build packages",
"ref": "refs/heads/main",
"cron": "0 1 * * 5",
"cron_timezone": "UTC",
"next_run_at": "2017-05-26T01:00:00.000Z",
"active": true,
"created_at": "2017-05-19T13:43:08.169Z",
"updated_at": "2017-05-19T13:43:08.169Z",
"last_pipeline": null,
"owner": {
"name": "Administrator",
"username": "root",
"id": 1,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "https://gitlab.example.com/root"
}
}
编辑流水线调度
更新项目的流水线调度。更新完成后,它会自动重新调度。
PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | Yes | 项目的 ID 或URL 编码路径 |
pipeline_schedule_id |
integer | Yes | 流水线调度 ID |
active |
boolean | No | 流水线调度的激活状态。如果设置为 false,流水线调度最初是未激活的。 |
cron_timezone |
string | No |
ActiveSupport::TimeZone 支持的时区(例如 Pacific Time (US & Canada) ),或 TZInfo::Timezone (例如 America/Los_Angeles )。 |
cron |
string | No | cron 调度,例如:0 1 * * * 。 |
description |
string | No | 流水线调度的描述。 |
ref |
string | No | 被触发的分支或标签名称。短版本(例如 main )和完整版本(例如 refs/heads/main 或 refs/tags/main )都可以接受。如果提供了短版本,它会自动扩展为完整版本,但如果 ref 是模糊的,则会被拒绝。 |
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" \
--form cron="0 2 * * *" "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13"
{
"id": 13,
"description": "Test schedule pipeline",
"ref": "refs/heads/main",
"cron": "0 2 * * *",
"cron_timezone": "Asia/Tokyo",
"next_run_at": "2017-05-19T17:00:00.000Z",
"active": true,
"created_at": "2017-05-19T13:31:08.849Z",
"updated_at": "2017-05-19T13:44:16.135Z",
"last_pipeline": {
"id": 332,
"sha": "0e788619d0b5ec17388dffb973ecd505946156db",
"ref": "refs/heads/main",
"status": "pending"
},
"owner": {
"name": "Administrator",
"username": "root",
"id": 1,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "https://gitlab.example.com/root"
}
}
获取流水线调度的所有权
更新项目的流水线调度的所有者。
POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/take_ownership
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | Yes | 项目的 ID 或URL 编码路径 |
pipeline_schedule_id |
integer | Yes | 流水线调度 ID |
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/take_ownership"
{
"id": 13,
"description": "Test schedule pipeline",
"ref": "refs/heads/main",
"cron": "0 2 * * *",
"cron_timezone": "Asia/Tokyo",
"next_run_at": "2017-05-19T17:00:00.000Z",
"active": true,
"created_at": "2017-05-19T13:31:08.849Z",
"updated_at": "2017-05-19T13:46:37.468Z",
"last_pipeline": {
"id": 332,
"sha": "0e788619d0b5ec17388dffb973ecd505946156db",
"ref": "refs/heads/main",
"status": "pending"
},
"owner": {
"name": "shinya",
"username": "maeda",
"id": 50,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/8ca0a796a679c292e3a11da50f99e801?s=80&d=identicon",
"web_url": "https://gitlab.example.com/maeda"
}
}
删除流水线调度
删除项目的流水线调度。
DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | Yes | 项目的 ID 或URL 编码路径 |
pipeline_schedule_id |
integer | Yes | 流水线调度 ID |
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13"
{
"id": 13,
"description": "Test schedule pipeline",
"ref": "refs/heads/main",
"cron": "0 2 * * *",
"cron_timezone": "Asia/Tokyo",
"next_run_at": "2017-05-19T17:00:00.000Z",
"active": true,
"created_at": "2017-05-19T13:31:08.849Z",
"updated_at": "2017-05-19T13:46:37.468Z",
"last_pipeline": {
"id": 332,
"sha": "0e788619d0b5ec17388dffb973ecd505946156db",
"ref": "refs/heads/main",
"status": "pending"
},
"owner": {
"name": "shinya",
"username": "maeda",
"id": 50,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/8ca0a796a679c292e3a11da50f99e801?s=80&d=identicon",
"web_url": "https://gitlab.example.com/maeda"
}
}
立即运行已调度的流水线
触发一个新的已调度流水线,该流水线立即运行。此流水线的下一次调度运行不受影响。
POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/play
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | Yes | 项目的 ID 或URL 编码路径 |
pipeline_schedule_id |
integer | Yes | 流水线调度 ID |
示例请求:
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/42/pipeline_schedules/1/play"
示例响应:
{
"message": "201 Created"
}
流水线调度变量
创建新的流水线调度变量
创建一个流水线调度的新变量。
POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | Yes | 项目的 ID 或URL 编码路径 |
key |
string | Yes | 变量的 key ;不得超过 255 个字符;仅允许 A-Z ,a-z ,0-9 和 _
|
pipeline_schedule_id |
integer | Yes | 流水线调度 ID |
value |
string | Yes | 变量的 value
|
variable_type |
string | No | 变量的类型。可用类型有:env_var (默认)和 file
|
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form "key=NEW_VARIABLE" \
--form "value=new value" "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables"
{
"key": "NEW_VARIABLE",
"variable_type": "env_var",
"value": "new value"
}
编辑流水线调度变量
更新流水线调度的变量。
PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | Yes | 项目的 ID 或URL 编码路径 |
key |
string | Yes | 变量的 key
|
pipeline_schedule_id |
integer | Yes | 流水线调度 ID |
value |
string | Yes | 变量的 value
|
variable_type |
string | No | 变量的类型。可用类型有:env_var (默认)和 file
|
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" \
--form "value=updated value" \
"https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables/NEW_VARIABLE"
{
"key": "NEW_VARIABLE",
"value": "updated value",
"variable_type": "env_var"
}
删除流水线调度变量
删除流水线调度的变量。
DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key
Attribute | Type | Required | Description |
---|---|---|---|
id |
integer/string | Yes | 项目的 ID 或URL 编码路径 |
key |
string | Yes | 变量的 key
|
pipeline_schedule_id |
integer | Yes | 流水线调度 ID |
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables/NEW_VARIABLE"
{
"key": "NEW_VARIABLE",
"value": "updated value"
}