2016-09-13 17:45:13 +05:30
# Pipelines API
## List project pipelines
> [Introduced][ce-5837] in GitLab 8.11
```
GET /projects/:id/pipelines
```
| Attribute | Type | Required | Description |
|-----------|---------|----------|---------------------|
2017-08-17 22:00:37 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
| `scope` | string | no | The scope of pipelines, one of: `running` , `pending` , `finished` , `branches` , `tags` |
| `status` | string | no | The status of pipelines, one of: `running` , `pending` , `success` , `failed` , `canceled` , `skipped` |
| `ref` | string | no | The ref of pipelines |
2018-10-15 14:42:47 +05:30
| `sha` | string | no | The sha or pipelines |
2017-08-17 22:00:37 +05:30
| `yaml_errors` | boolean | no | Returns pipelines with invalid configurations |
| `name` | string | no | The name of the user who triggered pipelines |
| `username` | string | no | The username of the user who triggered pipelines |
| `order_by` | string | no | Order pipelines by `id` , `status` , `ref` , or `user_id` (default: `id` ) |
| `sort` | string | no | Sort pipelines in `asc` or `desc` order (default: `desc` ) |
2016-09-13 17:45:13 +05:30
```
2019-02-15 15:39:39 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/pipelines"
2016-09-13 17:45:13 +05:30
```
Example of response
```json
[
{
"id": 47,
"status": "pending",
"ref": "new-pipeline",
2018-11-18 11:00:15 +05:30
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
"web_url": "https://example.com/foo/bar/pipelines/47"
2016-09-13 17:45:13 +05:30
},
{
"id": 48,
"status": "pending",
"ref": "new-pipeline",
2018-11-18 11:00:15 +05:30
"sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a",
"web_url": "https://example.com/foo/bar/pipelines/48"
2016-09-13 17:45:13 +05:30
}
]
```
## Get a single pipeline
> [Introduced][ce-5837] in GitLab 8.11
```
GET /projects/:id/pipelines/:pipeline_id
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
2017-08-17 22:00:37 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
2016-09-13 17:45:13 +05:30
| `pipeline_id` | integer | yes | The ID of a pipeline |
```
2019-02-15 15:39:39 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/pipelines/46"
2016-09-13 17:45:13 +05:30
```
Example of response
```json
{
"id": 46,
"status": "success",
"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",
2016-11-03 12:29:30 +05:30
"web_url": "http://localhost:3000/root"
2016-09-13 17:45:13 +05:30
},
"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,
2017-08-17 22:00:37 +05:30
"duration": null,
2018-11-18 11:00:15 +05:30
"coverage": "30.0",
"web_url": "https://example.com/foo/bar/pipelines/46"
2016-09-13 17:45:13 +05:30
}
```
2019-07-31 22:56:46 +05:30
### Get variables of a pipeline
```
GET /projects/:id/pipelines/:pipeline_id/variables
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
| `pipeline_id` | integer | yes | The ID of a pipeline |
```
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",
"variable_type": "env_var",
"value": "true"
},
{
"key": "foo",
"value": "bar"
}
]
```
2017-08-17 22:00:37 +05:30
## Create a new pipeline
> [Introduced][ce-7209] in GitLab 8.14
```
POST /projects/:id/pipeline
```
2019-09-30 21:07:59 +05:30
| Attribute | Type | Required | Description |
|-------------|---------|----------|---------------------|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
| `ref` | string | yes | Reference to commit |
| `variables` | array | no | An array containing the variables available in the pipeline, matching the structure `[{ 'key' => 'UPLOAD_TO_S3', 'variable_type' => 'file', 'value' => 'true' }]` |
2017-08-17 22:00:37 +05:30
```
2019-02-15 15:39:39 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/pipeline?ref=master"
2017-08-17 22:00:37 +05:30
```
Example of response
```json
{
"id": 61,
"sha": "384c444e840a515b23f21915ee5766b87068a70d",
"ref": "master",
"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,
"duration": null,
2018-11-18 11:00:15 +05:30
"coverage": null,
"web_url": "https://example.com/foo/bar/pipelines/61"
2017-08-17 22:00:37 +05:30
}
```
## Retry jobs in a pipeline
2016-09-13 17:45:13 +05:30
> [Introduced][ce-5837] in GitLab 8.11
```
POST /projects/:id/pipelines/:pipeline_id/retry
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
2017-08-17 22:00:37 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
2016-09-13 17:45:13 +05:30
| `pipeline_id` | integer | yes | The ID of a pipeline |
```
2019-02-15 15:39:39 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/pipelines/46/retry"
2016-09-13 17:45:13 +05:30
```
Response:
```json
{
"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",
2016-11-03 12:29:30 +05:30
"web_url": "http://localhost:3000/root"
2016-09-13 17:45:13 +05:30
},
"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,
2017-08-17 22:00:37 +05:30
"duration": null,
2018-11-18 11:00:15 +05:30
"coverage": null,
"web_url": "https://example.com/foo/bar/pipelines/46"
2016-09-13 17:45:13 +05:30
}
```
2017-08-17 22:00:37 +05:30
## Cancel a pipelines jobs
2016-09-13 17:45:13 +05:30
> [Introduced][ce-5837] in GitLab 8.11
```
POST /projects/:id/pipelines/:pipeline_id/cancel
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
2017-08-17 22:00:37 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
2016-09-13 17:45:13 +05:30
| `pipeline_id` | integer | yes | The ID of a pipeline |
```
2019-02-15 15:39:39 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/pipelines/46/cancel"
2016-09-13 17:45:13 +05:30
```
Response:
```json
{
"id": 46,
"status": "canceled",
"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",
2016-11-03 12:29:30 +05:30
"web_url": "http://localhost:3000/root"
2016-09-13 17:45:13 +05:30
},
"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,
2017-08-17 22:00:37 +05:30
"duration": null,
2018-11-18 11:00:15 +05:30
"coverage": null,
"web_url": "https://example.com/foo/bar/pipelines/46"
2016-09-13 17:45:13 +05:30
}
```
2019-02-15 15:39:39 +05:30
## Delete a pipeline
2019-12-04 20:38:33 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/22988) in GitLab 11.6.
2019-02-15 15:39:39 +05:30
```
DELETE /projects/:id/pipelines/:pipeline_id
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
| `pipeline_id` | integer | yes | The ID of a pipeline |
```
curl --header "PRIVATE-TOKEN: < your_access_token > " --request "DELETE" "https://gitlab.example.com/api/v4/projects/1/pipelines/46"
```
2019-12-04 20:38:33 +05:30
[ce-5837]: https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/5837
[ce-7209]: https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/7209