作业 API
列出项目作业
获取项目中的作业列表。作业按其 ID 降序排列。
默认情况下,因为 API 结果是分页的,所以此请求一次返回 20 个结果。
此端点支持基于偏移量和基于键集的分页。请求连续的结果页时,建议使用基于键集的分页。
GET /projects/:id/jobs
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| 整型/字符串 | 是 | 经过身份验证的用户拥有的项目的 ID 或 URL 编码的路径。 |
scope
| 字符串 或 字符串数组 | 否 | 要显示的作业范围。以下之一或数组:created 、pending 、running 、failed 、success 、canceled 、skipped 、waiting_for_resource 或 manual 。scope 如果未提供,则返回所有作业。
|
curl --globoff --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs?scope[]=pending&scope[]=running"
响应示例:
[
{
"commit": {
"author_email": "admin@example.com",
"author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.",
"short_id": "0ff3ae19",
"title": "Test the CI integration."
},
"coverage": null,
"allow_failure": false,
"created_at": "2015-12-24T15:51:21.802Z",
"started_at": "2015-12-24T17:54:27.722Z",
"finished_at": "2015-12-24T17:54:27.895Z",
"erased_at": null,
"duration": 0.173,
"queued_duration": 0.010,
"artifacts_file": {
"filename": "artifacts.zip",
"size": 1000
},
"artifacts": [
{"file_type": "archive", "size": 1000, "filename": "artifacts.zip", "file_format": "zip"},
{"file_type": "metadata", "size": 186, "filename": "metadata.gz", "file_format": "gzip"},
{"file_type": "trace", "size": 1500, "filename": "job.log", "file_format": "raw"},
{"file_type": "junit", "size": 750, "filename": "junit.xml.gz", "file_format": "gzip"}
],
"artifacts_expire_at": "2016-01-23T17:54:27.895Z",
"tag_list": [
"docker runner", "ubuntu18"
],
"id": 7,
"name": "teaspoon",
"pipeline": {
"id": 6,
"project_id": 1,
"ref": "main",
"sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "pending"
},
"ref": "main",
"runner": null,
"stage": "test",
"status": "failed",
"failure_reason": "script_failure",
"tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/7",
"project": {
"ci_job_token_scope_enabled": false
},
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://gitlab.dev/root",
"created_at": "2015-12-21T13:14:24.077Z",
"bio": null,
"location": null,
"public_email": "",
"skype": "",
"linkedin": "",
"twitter": "",
"website_url": "",
"organization": ""
}
},
{
"commit": {
"author_email": "admin@example.com",
"author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.",
"short_id": "0ff3ae19",
"title": "Test the CI integration."
},
"coverage": null,
"allow_failure": false,
"created_at": "2015-12-24T15:51:21.727Z",
"started_at": "2015-12-24T17:54:24.729Z",
"finished_at": "2015-12-24T17:54:24.921Z",
"erased_at": null,
"duration": 0.192,
"queued_duration": 0.023,
"artifacts_expire_at": "2016-01-23T17:54:24.921Z",
"tag_list": [
"docker runner", "win10-2004"
],
"id": 6,
"name": "rspec:other",
"pipeline": {
"id": 6,
"project_id": 1,
"ref": "main",
"sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "pending"
},
"ref": "main",
"artifacts": [],
"runner": null,
"stage": "test",
"status": "failed",
"failure_reason": "stuck_or_timeout_failure",
"tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/6",
"project": {
"ci_job_token_scope_enabled": false
},
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://gitlab.dev/root",
"created_at": "2015-12-21T13:14:24.077Z",
"bio": null,
"location": null,
"public_email": "",
"skype": "",
"linkedin": "",
"twitter": "",
"website_url": "",
"organization": ""
}
}
]
列出流水线作业
获取流水线的作业列表。
默认情况下,因为 API 结果是分页的,所以此请求一次返回 20 个结果。
GET /projects/:id/pipelines/:pipeline_id/jobs
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| 整型/字符串 | 是 | 经过身份验证的用户拥有的项目的 ID 或 URL 编码的路径。 |
pipeline_id
| 整型 | 是 | 流水线 ID。也可以通过预定义的 CI 变量 CI_PIPELINE_ID 在 CI 作业中获得。
|
scope
| 字符串 或 字符串数组 | 否 | 要显示的作业范围。以下之一或数组:created 、pending 、running 、failed 、success 、canceled 、skipped 、waiting_for_resource 或 manual 。scope 如果未提供,则返回所有作业。
|
include_retried
| 布尔 | 否 | 在响应中包括重试作业。默认为 false。在 13.9 版本中引入。 |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/pipelines/6/jobs?scope[]=pending&scope[]=running"
响应示例:
[
{
"commit": {
"author_email": "admin@example.com",
"author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.",
"short_id": "0ff3ae19",
"title": "Test the CI integration."
},
"coverage": null,
"allow_failure": false,
"created_at": "2015-12-24T15:51:21.727Z",
"started_at": "2015-12-24T17:54:24.729Z",
"finished_at": "2015-12-24T17:54:24.921Z",
"erased_at": null,
"duration": 0.192,
"queued_duration": 0.023,
"artifacts_expire_at": "2016-01-23T17:54:24.921Z",
"tag_list": [
"docker runner", "ubuntu18"
],
"id": 6,
"name": "rspec:other",
"pipeline": {
"id": 6,
"project_id": 1,
"ref": "main",
"sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "pending"
},
"ref": "main",
"artifacts": [],
"runner": null,
"stage": "test",
"status": "failed",
"failure_reason": "stuck_or_timeout_failure",
"tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/6",
"project": {
"ci_job_token_scope_enabled": false
},
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://gitlab.dev/root",
"created_at": "2015-12-21T13:14:24.077Z",
"bio": null,
"location": null,
"public_email": "",
"skype": "",
"linkedin": "",
"twitter": "",
"website_url": "",
"organization": ""
}
},
{
"commit": {
"author_email": "admin@example.com",
"author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.",
"short_id": "0ff3ae19",
"title": "Test the CI integration."
},
"coverage": null,
"allow_failure": false,
"created_at": "2015-12-24T15:51:21.802Z",
"started_at": "2015-12-24T17:54:27.722Z",
"finished_at": "2015-12-24T17:54:27.895Z",
"erased_at": null,
"duration": 0.173,
"queued_duration": 0.023,
"artifacts_file": {
"filename": "artifacts.zip",
"size": 1000
},
"artifacts": [
{"file_type": "archive", "size": 1000, "filename": "artifacts.zip", "file_format": "zip"},
{"file_type": "metadata", "size": 186, "filename": "metadata.gz", "file_format": "gzip"},
{"file_type": "trace", "size": 1500, "filename": "job.log", "file_format": "raw"},
{"file_type": "junit", "size": 750, "filename": "junit.xml.gz", "file_format": "gzip"}
],
"artifacts_expire_at": "2016-01-23T17:54:27.895Z",
"tag_list": [
"docker runner", "ubuntu18"
],
"id": 7,
"name": "teaspoon",
"pipeline": {
"id": 6,
"project_id": 1,
"ref": "main",
"sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "pending"
},
"ref": "main",
"runner": null,
"stage": "test",
"status": "failed",
"failure_reason": "script_failure",
"tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/7",
"project": {
"ci_job_token_scope_enabled": false
},
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://gitlab.dev/root",
"created_at": "2015-12-21T13:14:24.077Z",
"bio": null,
"location": null,
"public_email": "",
"skype": "",
"linkedin": "",
"twitter": "",
"website_url": "",
"organization": ""
}
}
]
在 13.3 及更高版本中,此端点返回任何流水线的数据,包括子流水线。
在 13.5 及更高版本中,默认情况下,此端点不会在响应中返回重试作业。此外,作业按 ID 降序排列(最新的优先)。在早期的版本中,作业按 ID 升序排序(最早的优先)。
在 13.9 及更高版本中,如果 include_retried
设置为 true
,此端点可以在响应中包含重试作业。
列出流水线触发作业
获取流水线的触发作业列表。
GET /projects/:id/pipelines/:pipeline_id/bridges
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| 整型/字符串 | 是 | 经过身份验证的用户拥有的项目的 ID 或 URL 编码的路径。 |
pipeline_id
| 整型 | 是 | 流水线 ID。 |
scope
| 字符串 或 字符串数组 | 否 | 要显示的作业范围。以下之一或数组:created 、pending 、running 、failed 、success 、canceled 、skipped 、waiting_for_resource 或 manual 。scope 如果未提供,则返回所有作业。
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/pipelines/6/bridges?scope[]=pending&scope[]=running"
响应示例:
[
{
"commit": {
"author_email": "admin@example.com",
"author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.",
"short_id": "0ff3ae19",
"title": "Test the CI integration."
},
"coverage": null,
"allow_failure": false,
"created_at": "2015-12-24T15:51:21.802Z",
"started_at": "2015-12-24T17:54:27.722Z",
"finished_at": "2015-12-24T17:58:27.895Z",
"erased_at": null,
"duration": 240,
"queued_duration": 0.123,
"id": 7,
"name": "teaspoon",
"pipeline": {
"id": 6,
"project_id": 1,
"ref": "main",
"sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "pending",
"created_at": "2015-12-24T15:50:16.123Z",
"updated_at": "2015-12-24T18:00:44.432Z",
"web_url": "https://example.com/foo/bar/pipelines/6"
},
"ref": "main",
"stage": "test",
"status": "pending",
"tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/7",
"project": {
"ci_job_token_scope_enabled": false
},
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://gitlab.dev/root",
"created_at": "2015-12-21T13:14:24.077Z",
"bio": null,
"location": null,
"public_email": "",
"skype": "",
"linkedin": "",
"twitter": "",
"website_url": "",
"organization": ""
},
"downstream_pipeline": {
"id": 5,
"sha": "f62a4b2fb89754372a346f24659212eb8da13601",
"ref": "main",
"status": "pending",
"created_at": "2015-12-24T17:54:27.722Z",
"updated_at": "2015-12-24T17:58:27.896Z",
"web_url": "https://example.com/diaspora/diaspora-client/pipelines/5"
}
}
]
获取作业令牌的作业
检索生成作业令牌的作业。
GET /job
示例(必须作为 CI/CD 作业 script
部分的一部分运行):
curl --header "Authorization: Bearer $CI_JOB_TOKEN" "${CI_API_V4_URL}/job"
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" "${CI_API_V4_URL}/job"
curl "${CI_API_V4_URL}/job?job_token=$CI_JOB_TOKEN"
响应示例:
{
"commit": {
"author_email": "admin@example.com",
"author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.",
"short_id": "0ff3ae19",
"title": "Test the CI integration."
},
"coverage": null,
"allow_failure": false,
"created_at": "2015-12-24T15:51:21.880Z",
"started_at": "2015-12-24T17:54:30.733Z",
"finished_at": "2015-12-24T17:54:31.198Z",
"erased_at": null,
"duration": 0.465,
"queued_duration": 0.123,
"artifacts_expire_at": "2016-01-23T17:54:31.198Z",
"id": 8,
"name": "rubocop",
"pipeline": {
"id": 6,
"project_id": 1,
"ref": "main",
"sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "pending"
},
"ref": "main",
"artifacts": [],
"runner": null,
"stage": "test",
"status": "failed",
"failure_reason": "script_failure",
"tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/8",
"project": {
"ci_job_token_scope_enabled": false
},
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://gitlab.dev/root",
"created_at": "2015-12-21T13:14:24.077Z",
"bio": null,
"location": null,
"public_email": "",
"skype": "",
"linkedin": "",
"twitter": "",
"website_url": "",
"organization": ""
}
}
通过 CI_JOB_TOKEN
获取极狐GitLab 代理
检索生成 CI_JOB_TOKEN
的作业以及允许的代理列表。
GET /job/allowed_agents
支持的属性:
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
CI_JOB_TOKEN
| 字符串 | 是 | CI_JOB_TOKEN 与极狐GitLab 提供的变量关联的令牌。 |
请求示例:
curl --header "JOB-TOKEN: <CI_JOB_TOKEN>" "https://gitlab.example.com/api/v4/job/allowed_agents"
curl "https://gitlab.example.com/api/v4/job/allowed_agents?job_token=<CI_JOB_TOKEN>"
响应示例:
{
"allowed_agents": [
{
"id": 1,
"config_project": {
"id": 1,
"description": null,
"name": "project1",
"name_with_namespace": "John Doe2 / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2022-11-16T14:51:50.579Z"
}
}
],
"job": {
"id": 1
},
"pipeline": {
"id": 2
},
"project": {
"id": 1,
"groups": [
{
"id": 1
},
{
"id": 2
},
{
"id": 3
}
]
},
"user": {
"id": 2,
"name": "John Doe3",
"username": "user2",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/10fc7f102b",
"web_url": "http://localhost/user2"
}
}
获取单个作业
获取项目的单个作业。
GET /projects/:id/jobs/:job_id
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| 整型/字符串 | 是 | 经过身份验证的用户拥有的项目的 ID 或 URL 编码的路径。 |
job_id
| 整型 | 是 | 作业 ID。 |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/8"
响应示例:
{
"commit": {
"author_email": "admin@example.com",
"author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.",
"short_id": "0ff3ae19",
"title": "Test the CI integration."
},
"coverage": null,
"allow_failure": false,
"created_at": "2015-12-24T15:51:21.880Z",
"started_at": "2015-12-24T17:54:30.733Z",
"finished_at": "2015-12-24T17:54:31.198Z",
"erased_at": null,
"duration": 0.465,
"queued_duration": 0.010,
"artifacts_expire_at": "2016-01-23T17:54:31.198Z",
"tag_list": [
"docker runner", "macos-10.15"
],
"id": 8,
"name": "rubocop",
"pipeline": {
"id": 6,
"project_id": 1,
"ref": "main",
"sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"status": "pending"
},
"ref": "main",
"artifacts": [],
"runner": null,
"stage": "test",
"status": "failed",
"tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/8",
"project": {
"ci_job_token_scope_enabled": false
},
"user": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://gitlab.dev/root",
"created_at": "2015-12-21T13:14:24.077Z",
"bio": null,
"location": null,
"public_email": "",
"skype": "",
"linkedin": "",
"twitter": "",
"website_url": "",
"organization": ""
}
}
获取日志文件
获取项目指定作业的日志或跟踪日志:
GET /projects/:id/jobs/:job_id/trace
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| 整型/字符串 | 是 | 经过身份验证的用户拥有的项目的 ID 或 URL 编码的路径。 |
job_id
| 整型 | 是 | 作业 ID。 |
curl --location --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/8/trace"
可能的响应状态代码:
状态 | 描述 |
---|---|
200 | 返回日志文件。 |
404 | 找不到作业或没有日志文件。 |
取消作业
取消项目的单个作业。
POST /projects/:id/jobs/:job_id/cancel
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| 整型/字符串 | 是 | 经过身份验证的用户拥有的项目的 ID 或 URL 编码的路径。 |
job_id
| 整型 | 是 | 作业 ID。 |
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/1/cancel"
响应示例:
{
"commit": {
"author_email": "admin@example.com",
"author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.",
"short_id": "0ff3ae19",
"title": "Test the CI integration."
},
"coverage": null,
"allow_failure": false,
"created_at": "2016-01-11T10:13:33.506Z",
"started_at": "2016-01-11T10:14:09.526Z",
"finished_at": null,
"erased_at": null,
"duration": 8,
"queued_duration": 0.010,
"id": 1,
"name": "rubocop",
"ref": "main",
"artifacts": [],
"runner": null,
"stage": "test",
"status": "canceled",
"tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/1",
"project": {
"ci_job_token_scope_enabled": false
},
"user": null
}
重试作业
重试项目的单个作业。
POST /projects/:id/jobs/:job_id/retry
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| 整型/字符串 | 是 | 经过身份验证的用户拥有的项目的 ID 或 URL 编码的路径。 |
job_id
| 整型 | 是 | 作业 ID。 |
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/1/retry"
响应示例:
{
"commit": {
"author_email": "admin@example.com",
"author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.",
"short_id": "0ff3ae19",
"title": "Test the CI integration."
},
"coverage": null,
"allow_failure": false,
"created_at": "2016-01-11T10:13:33.506Z",
"started_at": null,
"finished_at": null,
"erased_at": null,
"duration": null,
"queued_duration": 0.010,
"id": 1,
"name": "rubocop",
"ref": "main",
"artifacts": [],
"runner": null,
"stage": "test",
"status": "pending",
"tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/1",
"project": {
"ci_job_token_scope_enabled": false
},
"user": null
}
删除作业
删除项目的单个作业(删除作业产物和作业日志)。
POST /projects/:id/jobs/:job_id/erase
参数:
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| 整型/字符串 | 是 | 经过身份验证的用户拥有的项目的 ID 或 URL 编码的路径。 |
job_id
| 整型 | 是 | 作业 ID。 |
请求示例:
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/1/erase"
响应示例:
{
"commit": {
"author_email": "admin@example.com",
"author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.",
"short_id": "0ff3ae19",
"title": "Test the CI integration."
},
"coverage": null,
"allow_failure": false,
"download_url": null,
"id": 1,
"name": "rubocop",
"ref": "main",
"artifacts": [],
"runner": null,
"stage": "test",
"created_at": "2016-01-11T10:13:33.506Z",
"started_at": "2016-01-11T10:13:33.506Z",
"finished_at": "2016-01-11T10:15:10.506Z",
"erased_at": "2016-01-11T11:30:19.914Z",
"duration": 97.0,
"queued_duration": 0.010,
"status": "failed",
"tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/1",
"project": {
"ci_job_token_scope_enabled": false
},
"user": null
}
您无法使用 API 删除已归档的作业,但您可以从在特定日期之前完成的作业中删除作业产物和日志。
运行作业
对于手动状态的作业,触发手动操作以启动作业。
POST /projects/:id/jobs/:job_id/play
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| 整型/字符串 | 是 | 经过身份验证的用户拥有的项目的 ID 或 URL 编码的路径。 |
job_id
| 整型 | 是 | 作业 ID。 |
job_variables_attributes
| 哈希数组 | 否 | 包含可用于作业的自定义变量的数组。在 14.9 版本中引入。 |
请求示例:
curl --request POST "https://gitlab.example.com/api/v4/projects/1/jobs/1/play" \
--header "Content-Type: application/json" \
--header "PRIVATE-TOKEN: <your_access_token>" \
--data @variables.json
@variables.json
结构如下:
{
"job_variables_attributes": [
{
"key": "TEST_VAR_1",
"value": "test1"
},
{
"key": "TEST_VAR_2",
"value": "test2"
}
]
}
响应示例:
{
"commit": {
"author_email": "admin@example.com",
"author_name": "Administrator",
"created_at": "2015-12-24T16:51:14.000+01:00",
"id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
"message": "Test the CI integration.",
"short_id": "0ff3ae19",
"title": "Test the CI integration."
},
"coverage": null,
"allow_failure": false,
"created_at": "2016-01-11T10:13:33.506Z",
"started_at": null,
"finished_at": null,
"erased_at": null,
"duration": null,
"queued_duration": 0.010,
"id": 1,
"name": "rubocop",
"ref": "main",
"artifacts": [],
"runner": null,
"stage": "test",
"status": "pending",
"tag": false,
"web_url": "https://example.com/foo/bar/-/jobs/1",
"project": {
"ci_job_token_scope_enabled": false
},
"user": null
}