Jobs API

原文:https://docs.gitlab.com/ee/api/jobs.html

Jobs API

List project jobs

获取项目中的作业列表. 作业按 ID 的降序排列.

GET /projects/:id/jobs 
Attribute Type Required Description
id integer/string yes 身份验证用户拥有的项目的 ID 或URL 编码路径 .
scope 字符串字符串数组 no 要显示的工作范围. 以下一项或多项: createdpendingrunningfailedsuccesscanceledskippedmanual . 如果未提供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",  "duration":  0.173,  "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",  "id":  7,  "name":  "teaspoon",  "pipeline":  {  "id":  6,  "ref":  "master",  "sha":  "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",  "status":  "pending"  },  "ref":  "master",  "artifacts":  [],  "runner":  null,  "stage":  "test",  "status":  "failed",  "tag":  false,  "web_url":  "https://example.com/foo/bar/-/jobs/7",  "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",  "duration":  0.192,  "artifacts_expire_at":  "2016-01-23T17:54:24.921Z",  "id":  6,  "name":  "rspec:other",  "pipeline":  {  "id":  6,  "ref":  "master",  "sha":  "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",  "status":  "pending"  },  "ref":  "master",  "artifacts":  [],  "runner":  null,  "stage":  "test",  "status":  "failed",  "tag":  false,  "web_url":  "https://example.com/foo/bar/-/jobs/6",  "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":  ""  }  }  ] 

List pipeline jobs

获取管道的作业列表.

GET /projects/:id/pipelines/:pipeline_id/jobs 
Attribute Type Required Description
id integer/string yes 身份验证用户拥有的项目的 ID 或URL 编码路径 .
pipeline_id integer yes 管道的 ID.
scope 字符串字符串数组 no 要显示的工作范围. 以下一项或多项: createdpendingrunningfailedsuccesscanceledskippedmanual . 如果未提供scope则返回所有作业.
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",  "duration":  0.192,  "artifacts_expire_at":  "2016-01-23T17:54:24.921Z",  "id":  6,  "name":  "rspec:other",  "pipeline":  {  "id":  6,  "ref":  "master",  "sha":  "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",  "status":  "pending"  },  "ref":  "master",  "artifacts":  [],  "runner":  null,  "stage":  "test",  "status":  "failed",  "tag":  false,  "web_url":  "https://example.com/foo/bar/-/jobs/6",  "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",  "duration":  0.173,  "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",  "id":  7,  "name":  "teaspoon",  "pipeline":  {  "id":  6,  "ref":  "master",  "sha":  "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",  "status":  "pending"  },  "ref":  "master",  "artifacts":  [],  "runner":  null,  "stage":  "test",  "status":  "failed",  "tag":  false,  "web_url":  "https://example.com/foo/bar/-/jobs/7",  "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":  ""  }  }  ] 

从 GitLab 13.2 开始,此端点将返回任何管道(包括子管道)的数据 .

List pipeline bridges

获取管道的桥作业列表.

GET /projects/:id/pipelines/:pipeline_id/bridges 
Attribute Type Required Description
id integer/string yes 身份验证用户拥有的项目的 ID 或URL 编码路径 .
pipeline_id integer yes 管道的 ID.
scope 字符串字符串数组 no 要显示的工作范围. 以下一项或多项: createdpendingrunningfailedsuccesscanceledskippedmanual . 如果未提供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",  "duration":  240,  "id":  7,  "name":  "teaspoon",  "pipeline":  {  "id":  6,  "ref":  "master",  "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":  "master",  "stage":  "test",  "status":  "pending",  "tag":  false,  "web_url":  "https://example.com/foo/bar/-/jobs/7",  "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":  "master",  "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 a single job

获得项目的一份工作

GET /projects/:id/jobs/:job_id 
Attribute Type Required Description
id integer/string yes 身份验证用户拥有的项目的 ID 或URL 编码路径 .
job_id integer yes 工作 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",  "duration":  0.465,  "artifacts_expire_at":  "2016-01-23T17:54:31.198Z",  "id":  8,  "name":  "rubocop",  "pipeline":  {  "id":  6,  "ref":  "master",  "sha":  "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",  "status":  "pending"  },  "ref":  "master",  "artifacts":  [],  "runner":  null,  "stage":  "test",  "status":  "failed",  "tag":  false,  "web_url":  "https://example.com/foo/bar/-/jobs/8",  "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 job artifacts

版本历史

注意事项

获取项目的工件压缩文件存档.

GET /projects/:id/jobs/:job_id/artifacts 
Attribute Type Required Description
id integer/string yes 身份验证用户拥有的项目的 ID 或URL 编码路径 .
job_id integer yes 工作 ID.
job_token string no 与多项目管道的触发器一起使用. 它只能在.gitlab-ci.yml内部调用. 其值始终$CI_JOB_TOKEN .

使用PRIVATE-TOKEN标头的示例请求:

curl --output artifacts.zip --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/42/artifacts" 

要在.gitlab-ci.yml中的script定义中使用它 ,您可以使用以下任一方法:

  • GitLab 提供的CI_JOB_TOKEN变量的JOB-TOKEN标头. 例如,以下作业将下载 ID 为42的作业工件. 注意,该命令被缠绕成单引号,因为它含有一个冒号( : ):

    artifact_download:
      stage: test
      script:
        - 'curl  --location  --output  artifacts.zip  --header  "JOB-TOKEN:  $CI_JOB_TOKEN"  "https://gitlab.example.com/api/v4/projects/1/jobs/42/artifacts"' 
    • 或带有 GitLab 提供的CI_JOB_TOKEN变量的job_token属性. 例如,以下作业将下载 ID 为42的作业的工件:
    artifact_download:
      stage: test
      script:
        - 'curl  --location  --output  artifacts.zip  "https://gitlab.example.com/api/v4/projects/1/jobs/42/artifacts?job_token=$CI_JOB_TOKEN"' 

可能的响应状态代码:

Status Description
200 Serves the artifacts file.
404 找不到构建或没有工件.

Download the artifacts archive

版本历史

注意事项

如果作业成功完成,请从最新成功的管道中下载给定参考名称和作业的工件压缩存档. 这与获取作业的工件相同 ,但是通过定义作业的名称而不是其 ID.

GET /projects/:id/jobs/artifacts/:ref_name/download?job=name 

Parameters

Attribute Type Required Description
id integer/string yes 身份验证用户拥有的项目的 ID 或URL 编码路径 .
ref_name string yes 存储库中的分支或标记名称. 不支持 HEAD 或 SHA 引用.
job string yes 工作名称.
job_token string no 与多项目管道的触发器一起使用. 它只能在.gitlab-ci.yml内部调用. 其值始终$CI_JOB_TOKEN .

使用PRIVATE-TOKEN标头的示例请求:

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/artifacts/master/download?job=test" 

要在.gitlab-ci.yml中的script定义中使用它 ,您可以使用以下任一方法:

  • GitLab 提供的CI_JOB_TOKEN变量的JOB-TOKEN标头. 例如,以下作业将下载master分支的test作业的工件. 注意,该命令被缠绕成单引号,因为它含有一个冒号( : ):

    artifact_download:
      stage: test
      script:
        - 'curl  --location  --output  artifacts.zip  --header  "JOB-TOKEN:  $CI_JOB_TOKEN"  "https://gitlab.example.com/api/v4/projects/$CI_PROJECT_ID/jobs/artifacts/master/download?job=test"' 
    • 或带有 GitLab 提供的CI_JOB_TOKEN变量的job_token属性. 例如,以下作业将下载master分支的test作业的工件:
    artifact_download:
      stage: test
      script:
        - 'curl  --location  --output  artifacts.zip  "https://gitlab.example.com/api/v4/projects/$CI_PROJECT_ID/jobs/artifacts/master/download?job=test&job_token=$CI_JOB_TOKEN"' 

可能的响应状态代码:

Status Description
200 服务工件文件.
404 找不到构建或没有工件.

Download a single artifact file by job ID

在 GitLab 10.0 中引入

从作业的工件压缩文件中以指定的 ID 下载作业中的单个工件文件. 从存档中提取文件,并将其流式传输到客户端.

GET /projects/:id/jobs/:job_id/artifacts/*artifact_path 

Parameters

Attribute Type Required Description
id integer/string yes 身份验证用户拥有的项目的 ID 或URL 编码路径 .
job_id integer yes 唯一的作业标识符.
artifact_path string yes 工件存档内文件的路径.

请求示例:

curl --location --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/5/artifacts/some/release/file.pdf" 

可能的响应状态代码:

Status Description
200 发送单个工件文件
400 提供的路径无效
404 找不到版本或没有文件/工件

Download a single artifact file from specific tag or branch

在 GitLab 11.5 中引入 .

从作业的工件存档中为给定的参考名称下载最新成功管道的特定作业的单个工件文件. 从存档中提取文件,并将其流式传输到客户端.

GET /projects/:id/jobs/artifacts/:ref_name/raw/*artifact_path?job=name 

Parameters:

Attribute Type Required Description
id integer/string yes 身份验证用户拥有的项目的 ID 或URL 编码路径 .
ref_name string yes 存储库中的分支或标记名称. 不支持 HEAD 或 SHA 引用.
artifact_path string yes 工件存档内文件的路径.
job string yes 工作名称.

请求示例:

curl --location --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/artifacts/master/raw/some/release/file.pdf?job=pdf" 

可能的响应状态代码:

Status Description
200 发送单个工件文件
400 提供的路径无效
404 找不到版本或没有文件/工件

Get a log file

获取项目的特定作业的日志(跟踪):

GET /projects/:id/jobs/:job_id/trace 
Attribute Type Required Description
id integer/string yes 身份验证用户拥有的项目的 ID 或URL 编码路径 .
job_id integer yes 工作 ID.
curl --location --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/8/trace" 

可能的响应状态代码:

Status Description
200 服务日志文件
404 找不到作业或没有日志文件

Cancel a job

取消项目的一项工作

POST /projects/:id/jobs/:job_id/cancel 
Attribute Type Required Description
id integer/string yes 身份验证用户拥有的项目的 ID 或URL 编码路径 .
job_id integer yes 工作 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,  "duration":  8,  "id":  42,  "name":  "rubocop",  "ref":  "master",  "artifacts":  [],  "runner":  null,  "stage":  "test",  "status":  "canceled",  "tag":  false,  "web_url":  "https://example.com/foo/bar/-/jobs/42",  "user":  null  } 

Retry a job

重试项目的一项工作

POST /projects/:id/jobs/:job_id/retry 
Attribute Type Required Description
id integer/string yes 身份验证用户拥有的项目的 ID 或URL 编码路径 .
job_id integer yes 工作 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,  "duration":  null,  "id":  42,  "name":  "rubocop",  "ref":  "master",  "artifacts":  [],  "runner":  null,  "stage":  "test",  "status":  "pending",  "tag":  false,  "web_url":  "https://example.com/foo/bar/-/jobs/42",  "user":  null  } 

Erase a job

擦除项目的单个作业(删除作业工件和作业日志)

POST /projects/:id/jobs/:job_id/erase 

Parameters

Attribute Type Required Description
id integer/string yes 身份验证用户拥有的项目的 ID 或URL 编码路径 .
job_id integer yes 工作 ID.

Example of request

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":  42,  "name":  "rubocop",  "ref":  "master",  "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",  "duration":  97.0,  "status":  "failed",  "tag":  false,  "web_url":  "https://example.com/foo/bar/-/jobs/42",  "user":  null  } 

Keep artifacts

设置过期时,防止删除工件.

POST /projects/:id/jobs/:job_id/artifacts/keep 

Parameters

Attribute Type Required Description
id integer/string yes 身份验证用户拥有的项目的 ID 或URL 编码路径 .
job_id integer yes 工作 ID.

请求示例:

curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/1/artifacts/keep" 

响应示例:

{  "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":  42,  "name":  "rubocop",  "ref":  "master",  "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",  "duration":  97.0,  "status":  "failed",  "tag":  false,  "web_url":  "https://example.com/foo/bar/-/jobs/42",  "user":  null  } 

Delete artifacts

在 GitLab 11.9 中引入 .

删除作业的工件.

DELETE /projects/:id/jobs/:job_id/artifacts 
Attribute Type Required Description
id integer/string yes 项目的 ID 或URL 编码的路径
job_id integer yes 工作 ID.

请求示例:

curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/1/artifacts" 

注意:至少需要具有维护者角色才能删除工件.

如果工件被成功删除,则返回状态为204 No Content的响应.

Play a job

触发手动操作以开始作业.

POST /projects/:id/jobs/:job_id/play 
Attribute Type Required Description
id integer/string yes 身份验证用户拥有的项目的 ID 或URL 编码路径 .
job_id integer yes 工作 ID.
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/jobs/1/play" 

回应范例

{  "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,  "duration":  null,  "id":  42,  "name":  "rubocop",  "ref":  "master",  "artifacts":  [],  "runner":  null,  "stage":  "test",  "status":  "started",  "tag":  false,  "web_url":  "https://example.com/foo/bar/-/jobs/42",  "user":  null  } 
Copyright © 温玉 2021 | 浙ICP备2020032454号 all right reserved,powered by Gitbook该文件修订时间: 2021-03-27 13:48:25

results matching ""

    No results matching ""