2020-08-04 02:10:16 -04:00
---
stage: Verify
2021-05-26 11:10:57 -04:00
group: Pipeline Execution
2020-11-26 01:09:20 -05:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-08-04 02:10:16 -04:00
---
2021-05-30 23:10:48 -04:00
# Pipelines API **(FREE)**
2016-08-17 09:23:58 -04:00
2020-07-17 14:09:20 -04:00
## Single Pipeline Requests
2020-07-24 20:09:23 -04:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/36494) in GitLab 13.3.
2020-07-17 14:09:20 -04:00
Endpoints that request information about a single pipeline return data for any pipeline.
2021-06-30 11:08:27 -04:00
Before 13.3, requests for [child pipelines ](../ci/pipelines/parent_child_pipelines.md ) returned
2020-07-17 14:09:20 -04:00
a 404 error.
2020-05-19 02:08:03 -04:00
## Pipelines pagination
By default, `GET` requests return 20 results at a time because the API results
are paginated.
2021-06-28 11:08:03 -04:00
Read more on [pagination ](index.md#pagination ).
2020-05-19 02:08:03 -04:00
2016-08-17 09:23:58 -04:00
## List project pipelines
2020-02-27 19:09:08 -05:00
```plaintext
2016-08-17 09:23:58 -04:00
GET /projects/:id/pipelines
```
| Attribute | Type | Required | Description |
|-----------|---------|----------|---------------------|
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2017-04-05 07:48:59 -04:00
| `scope` | string | no | The scope of pipelines, one of: `running` , `pending` , `finished` , `branches` , `tags` |
2020-08-09 17:10:01 -04:00
| `status` | string | no | The status of pipelines, one of: `created` , `waiting_for_resource` , `preparing` , `pending` , `running` , `success` , `failed` , `canceled` , `skipped` , `manual` , `scheduled` |
2017-02-28 07:24:49 -05:00
| `ref` | string | no | The ref of pipelines |
2020-03-25 23:07:43 -04:00
| `sha` | string | no | The SHA of pipelines |
2017-04-27 09:09:18 -04:00
| `yaml_errors` | boolean | no | Returns pipelines with invalid configurations |
2017-04-05 07:48:59 -04:00
| `name` | string | no | The name of the user who triggered pipelines |
| `username` | string | no | The username of the user who triggered pipelines |
2020-10-30 17:08:52 -04:00
| `updated_after` | datetime | no | Return pipelines updated after the specified date. Expected in ISO 8601 format (`2019-03-15T08:00:00Z`). |
| `updated_before` | datetime | no | Return pipelines updated before the specified date. Expected in ISO 8601 format (`2019-03-15T08:00:00Z`). |
2019-11-22 13:06:00 -05:00
| `order_by` | string | no | Order pipelines by `id` , `status` , `ref` , `updated_at` or `user_id` (default: `id` ) |
2017-04-27 09:09:18 -04:00
| `sort` | string | no | Sort pipelines in `asc` or `desc` order (default: `desc` ) |
2016-08-17 09:23:58 -04:00
2020-02-27 19:09:08 -05:00
```shell
2018-12-27 04:03:08 -05:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/pipelines"
2016-08-17 09:23:58 -04:00
```
Example of response
```json
[
{
"id": 47,
2021-03-15 14:09:05 -04:00
"project_id": 1,
2016-08-17 09:23:58 -04:00
"status": "pending",
"ref": "new-pipeline",
2018-07-18 17:57:08 -04:00
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
2019-10-04 14:05:55 -04:00
"web_url": "https://example.com/foo/bar/pipelines/47",
"created_at": "2016-08-11T11:28:34.085Z",
2021-04-29 08:09:58 -04:00
"updated_at": "2016-08-11T11:32:35.169Z"
2016-08-17 09:23:58 -04:00
},
{
"id": 48,
2021-03-15 14:09:05 -04:00
"project_id": 1,
2016-08-17 09:23:58 -04:00
"status": "pending",
"ref": "new-pipeline",
2018-07-18 17:57:08 -04:00
"sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a",
2019-10-04 14:05:55 -04:00
"web_url": "https://example.com/foo/bar/pipelines/48",
"created_at": "2016-08-12T10:06:04.561Z",
2021-04-29 08:09:58 -04:00
"updated_at": "2016-08-12T10:09:56.223Z"
2016-08-17 09:23:58 -04:00
}
]
```
## Get a single pipeline
2020-02-27 19:09:08 -05:00
```plaintext
2016-08-17 09:23:58 -04:00
GET /projects/:id/pipelines/:pipeline_id
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2016-08-17 09:23:58 -04:00
| `pipeline_id` | integer | yes | The ID of a pipeline |
2020-02-27 19:09:08 -05:00
```shell
2018-12-27 04:03:08 -05:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/pipelines/46"
2016-08-17 09:23:58 -04:00
```
Example of response
```json
{
"id": 46,
2021-03-15 14:09:05 -04:00
"project_id": 1,
2016-08-17 09:23:58 -04:00
"status": "success",
2021-05-27 11:10:39 -04:00
"ref": "main",
2016-08-17 09:23:58 -04:00
"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",
2016-10-13 07:24:09 -04:00
"web_url": "http://localhost:3000/root"
2016-08-17 09:23:58 -04:00
},
"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,
2021-04-26 14:09:45 -04:00
"duration": 123.65,
"queued_duration": 0.010,
2018-07-18 17:57:08 -04:00
"coverage": "30.0",
"web_url": "https://example.com/foo/bar/pipelines/46"
2016-08-17 09:23:58 -04:00
}
```
2019-04-09 10:53:44 -04:00
### Get variables of a pipeline
2020-02-27 19:09:08 -05:00
```plaintext
2019-04-09 10:53:44 -04:00
GET /projects/:id/pipelines/:pipeline_id/variables
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2019-04-09 10:53:44 -04:00
| `pipeline_id` | integer | yes | The ID of a pipeline |
2020-02-27 19:09:08 -05:00
```shell
2019-04-09 10:53:44 -04:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/pipelines/46/variables"
```
Example of response
```json
[
{
"key": "RUN_NIGHTLY_BUILD",
2019-05-06 09:11:42 -04:00
"variable_type": "env_var",
2019-04-09 10:53:44 -04:00
"value": "true"
},
{
"key": "foo",
"value": "bar"
}
]
```
2020-05-11 08:10:28 -04:00
### Get a pipeline's test report
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/202525) in GitLab 13.0.
2020-12-04 16:09:29 -05:00
NOTE:
2020-08-21 17:10:01 -04:00
This API route is part of the [Unit test report ](../ci/unit_test_reports.md ) feature.
2020-05-11 08:10:28 -04:00
```plaintext
GET /projects/:id/pipelines/:pipeline_id/test_report
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2020-05-11 08:10:28 -04:00
| `pipeline_id` | integer | yes | The ID of a pipeline |
Sample request:
```shell
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/pipelines/46/test_report"
```
Sample response:
```json
{
"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
}
]
}
]
}
```
2016-10-31 16:38:24 -04:00
## Create a new pipeline
2020-02-27 19:09:08 -05:00
```plaintext
2016-10-31 16:38:24 -04:00
POST /projects/:id/pipeline
```
2019-07-04 18:46:12 -04:00
| Attribute | Type | Required | Description |
|-------------|---------|----------|---------------------|
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2019-07-04 18:46:12 -04:00
| `ref` | string | yes | Reference to commit |
2020-07-28 14:09:36 -04:00
| `variables` | array | no | An array containing the variables available in the pipeline, matching the structure `[{ 'key': 'UPLOAD_TO_S3', 'variable_type': 'file', 'value': 'true' }]` |
2016-10-31 16:38:24 -04:00
2020-02-27 19:09:08 -05:00
```shell
2021-05-27 11:10:39 -04:00
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/pipeline?ref=main"
2016-10-31 16:38:24 -04:00
```
Example of response
```json
{
"id": 61,
2021-03-15 14:09:05 -04:00
"project_id": 1,
2016-10-31 16:38:24 -04:00
"sha": "384c444e840a515b23f21915ee5766b87068a70d",
2021-05-27 11:10:39 -04:00
"ref": "main",
2016-10-31 16:38:24 -04:00
"status": "pending",
"before_sha": "0000000000000000000000000000000000000000",
"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-11-04T09:36:13.747Z",
"updated_at": "2016-11-04T09:36:13.977Z",
"started_at": null,
"finished_at": null,
"committed_at": null,
2016-11-25 11:38:51 -05:00
"duration": null,
2021-04-26 14:09:45 -04:00
"queued_duration": 0.010,
2018-07-18 17:57:08 -04:00
"coverage": null,
"web_url": "https://example.com/foo/bar/pipelines/61"
2016-10-31 16:38:24 -04:00
}
```
2017-03-06 04:24:03 -05:00
## Retry jobs in a pipeline
2016-08-17 09:23:58 -04:00
2020-02-27 19:09:08 -05:00
```plaintext
2016-08-17 09:23:58 -04:00
POST /projects/:id/pipelines/:pipeline_id/retry
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2016-08-17 09:23:58 -04:00
| `pipeline_id` | integer | yes | The ID of a pipeline |
2020-02-27 19:09:08 -05:00
```shell
2018-12-27 04:03:08 -05:00
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/pipelines/46/retry"
2016-08-17 09:23:58 -04:00
```
Response:
```json
{
"id": 46,
2021-03-15 14:09:05 -04:00
"project_id": 1,
2016-08-17 09:23:58 -04:00
"status": "pending",
2021-05-27 11:10:39 -04:00
"ref": "main",
2016-08-17 09:23:58 -04:00
"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",
2016-10-13 07:24:09 -04:00
"web_url": "http://localhost:3000/root"
2016-08-17 09:23:58 -04:00
},
"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,
2016-11-25 11:38:51 -05:00
"duration": null,
2021-04-26 14:09:45 -04:00
"queued_duration": 0.010,
2018-07-18 17:57:08 -04:00
"coverage": null,
"web_url": "https://example.com/foo/bar/pipelines/46"
2016-08-17 09:23:58 -04:00
}
```
2020-05-03 23:09:50 -04:00
## Cancel a pipeline's jobs
2016-08-17 09:23:58 -04:00
2020-02-27 19:09:08 -05:00
```plaintext
2016-08-17 09:23:58 -04:00
POST /projects/:id/pipelines/:pipeline_id/cancel
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2016-08-17 09:23:58 -04:00
| `pipeline_id` | integer | yes | The ID of a pipeline |
2020-02-27 19:09:08 -05:00
```shell
2018-12-27 04:03:08 -05:00
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/pipelines/46/cancel"
2016-08-17 09:23:58 -04:00
```
Response:
```json
{
"id": 46,
2021-03-15 14:09:05 -04:00
"project_id": 1,
2016-08-17 09:23:58 -04:00
"status": "canceled",
2021-05-27 11:10:39 -04:00
"ref": "main",
2016-08-17 09:23:58 -04:00
"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",
2016-10-13 07:24:09 -04:00
"web_url": "http://localhost:3000/root"
2016-08-17 09:23:58 -04:00
},
"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,
2016-11-25 11:38:51 -05:00
"duration": null,
2021-04-26 14:09:45 -04:00
"queued_duration": 0.010,
2018-07-18 17:57:08 -04:00
"coverage": null,
"web_url": "https://example.com/foo/bar/pipelines/46"
2016-08-17 09:23:58 -04:00
}
```
2018-11-13 07:58:24 -05:00
## Delete a pipeline
2020-02-06 10:09:11 -05:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/22988) in GitLab 11.6.
2018-11-13 07:58:24 -05:00
2020-02-27 19:09:08 -05:00
```plaintext
2018-11-13 07:58:24 -05:00
DELETE /projects/:id/pipelines/:pipeline_id
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2018-11-13 07:58:24 -05:00
| `pipeline_id` | integer | yes | The ID of a pipeline |
2020-02-27 19:09:08 -05:00
```shell
2018-12-27 04:03:08 -05:00
curl --header "PRIVATE-TOKEN: < your_access_token > " --request "DELETE" "https://gitlab.example.com/api/v4/projects/1/pipelines/46"
2018-11-13 07:58:24 -05:00
```