Pipelines API

Pipelines API

在 GitLab 13.2 中引入 .

请求有关单个管道的信息的端点返回任何管道的数据. 在 13.2 之前, 请求返回了 404 错误.

Pipelines pagination

默认情况下,因为 API 结果是分页的,所以请求一次返回 20 个结果.

阅读有关更多信息.

在 GitLab 8.11 中引入

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

回应范例

  1. [ { "id": 47, "status": "pending", "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, "status": "pending", "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", } ]

Get a single pipeline

  1. GET /projects/:id/pipelines/:pipeline_id
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或
pipeline_id integer yes 管道的 ID
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/pipelines/46"

回应范例

    1. GET /projects/:id/pipelines/:pipeline_id/variables

    回应范例

    Get a pipeline’s test report

    在 GitLab 13.0 中 .

    警告:此 API 路由是JUnit 测试报告功能的一部分. 它受一个保护,该功能标志由于非常大的数据集的性能问题而被禁用 .

    1. GET /projects/:id/pipelines/:pipeline_id/test_report
    Attribute Type Required Description
    id integer/string yes 经过身份验证的用户拥有的 ID 或URL 编码路径
    pipeline_id integer yes The ID of a pipeline

    样品要求:

    1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/pipelines/46/test_report"

    样本回复:

    1. { "total_time": 5, "total_count": 1, "success_count": 1, "failed_count": 0, "skipped_count": 0, "error_count": 0, "test_suites": [ { "name": "Secure", "total_time": 5, "total_count": 1, "success_count": 1, "failed_count": 0, "skipped_count": 0, "error_count": 0, "test_cases": [ { "status": "success", "name": "Security Reports can create an auto-remediation MR", "classname": "vulnerability_management_spec", "execution_time": 5, "system_output": null, "stack_trace": null } ] } ] }
    1. POST /projects/:id/pipeline
    1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/pipeline?ref=master"

    回应范例

    Retry jobs in a pipeline

    在 GitLab 8.11 中引入

    1. POST /projects/:id/pipelines/:pipeline_id/retry
    Attribute Type Required Description
    id integer/string yes 经过身份验证的用户拥有的 ID 或URL 编码路径
    pipeline_id integer yes 管道的 ID
    1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/pipelines/46/retry"

    Response:

    1. { "id": 46, "status": "pending", "ref": "master", "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", "before_sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", "tag": false, "yaml_errors": null, "user": { "name": "Administrator", "username": "root", "id": 1, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "web_url": "http://localhost:3000/root" }, "created_at": "2016-08-11T11:28:34.085Z", "updated_at": "2016-08-11T11:32:35.169Z", "started_at": null, "finished_at": "2016-08-11T11:32:35.145Z", "committed_at": null, "duration": null, "coverage": null, "web_url": "https://example.com/foo/bar/pipelines/46" }

    在 GitLab 8.11 中

    1. POST /projects/:id/pipelines/:pipeline_id/cancel
    1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/pipelines/46/cancel"

    Response:

      Delete a pipeline

      在 GitLab 11.6 中 .

      Attribute Type Required Description
      id integer/string yes 经过身份验证的用户拥有的项目的 ID 或
      integer yes 管道的 ID
      1. curl --header "PRIVATE-TOKEN: <your_access_token>" --request "DELETE" "https://gitlab.example.com/api/v4/projects/1/pipelines/46"