- Pipeline schedules API
- Pipeline schedules API
- Get all pipeline schedules
- Get a single pipeline schedule
- Create a new pipeline schedule
- Edit a pipeline schedule
- Take ownership of a pipeline schedule
- Delete a pipeline schedule
- Run a scheduled pipeline immediately
- Pipeline schedule variables
- Create a new pipeline schedule variable
- Edit a pipeline schedule variable
- Delete a pipeline schedule variable
Pipeline schedules API
- Get all pipeline schedules
- Get a single pipeline schedule
- Create a new pipeline schedule
- Edit a pipeline schedule
- Take ownership of a pipeline schedule
- Delete a pipeline schedule
- Run a scheduled pipeline immediately
- Pipeline schedule variables
- Create a new pipeline schedule variable
- Edit a pipeline schedule variable
- Delete a pipeline schedule variable
Pipeline schedules API
您可以阅读有关管道计划的更多信息.
Get all pipeline schedules
获取项目的管道时间表的列表.
GET /projects/:id/pipeline_schedules
Attribute | Type | required | Description |
---|---|---|---|
id |
integer/string | yes | The ID or URL-encoded path of the project owned by the authenticated user |
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": "master", "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 a single pipeline schedule
获取项目的管道计划.
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": "master", "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": "master", "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" } ] }
Create a new pipeline schedule
创建一个新的项目管道计划.
POST /projects/:id/pipeline_schedules
Attribute | Type | required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目的 ID 或URL 编码路径 |
description |
string | yes | 管道进度表的描述 |
ref |
string | yes | 分支/标签名称将被触发 |
cron |
string | yes | cron(例如0 1 * * * )( Cron 语法 ) |
cron_timezone |
string | no | ActiveSupport::TimeZone 支持的时ActiveSupport::TimeZone (例如Pacific Time (US & Canada) )(默认值: 'UTC' ) |
active |
boolean | no | 激活管道计划. 如果设置为 false,则管道调度最初将被停用(默认值: true ) |
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form description="Build packages" --form ref="master" --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": "master", "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" } }
Edit a pipeline schedule
更新项目的管道计划. 更新完成后,将自动重新安排.
PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id
Attribute | Type | required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目的 ID 或URL 编码路径 |
pipeline_schedule_id |
integer | yes | 管道时间表 ID |
description |
string | no | 管道进度表的描述 |
ref |
string | no | 分支/标签名称将被触发 |
cron |
string | no | cron(例如0 1 * * * )( Cron 语法 ) |
cron_timezone |
string | no | ActiveSupport::TimeZone (例如Pacific Time (US & Canada) )或TZInfo::Timezone (例如America/Los_Angeles )支持的TZInfo::Timezone |
active |
boolean | no | 激活管道计划. 如果设置为 false,则管道计划将首先停用. |
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": "master", "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": "master", "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" } }
Take ownership of a pipeline schedule
更新项目的管道计划的所有者.
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": "master", "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": "master", "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 a pipeline schedule
删除项目的管道计划.
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": "master", "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": "master", "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" } }
Run a scheduled pipeline immediately
在 GitLab 12.8 中引入 .
触发一个新的计划管道,该管道将立即运行. 该管道的下一个计划运行不受影响.
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" }
Pipeline schedule variables
在 GitLab 10.0 中引入 .
Create a new pipeline schedule variable
创建管道计划的新变量.
POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables
Attribute | Type | required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目的 ID 或URL 编码路径 |
pipeline_schedule_id |
integer | yes | 管道时间表 ID |
key |
string | yes | 变量的key ; 不得超过 255 个字符; 仅允许AZ , az , 0-9 和_ |
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" }
Edit a pipeline schedule variable
更新管道计划的变量.
PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key
Attribute | Type | required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目的 ID 或URL 编码路径 |
pipeline_schedule_id |
integer | yes | 管道时间表 ID |
key |
string | yes | 变量的key |
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 a pipeline schedule variable
删除管道计划的变量.
DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key
Attribute | Type | required | Description |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目的 ID 或URL 编码路径 |
pipeline_schedule_id |
integer | yes | 管道时间表 ID |
key |
string | yes | 变量的key |
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" }