2016-08-17 13:23:58 +00:00
# Pipelines API
## List project pipelines
> [Introduced][ce-5837] in GitLab 8.11
```
GET /projects/:id/pipelines
```
| Attribute | Type | Required | Description |
|-----------|---------|----------|---------------------|
2017-04-08 09:21:11 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
2017-04-05 11:48:59 +00:00
| `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` |
2017-02-28 12:24:49 +00:00
| `ref` | string | no | The ref of pipelines |
2018-04-01 21:16:35 +00:00
| `sha` | string | no | The sha or pipelines |
2017-04-27 13:09:18 +00:00
| `yaml_errors` | boolean | no | Returns pipelines with invalid configurations |
2017-04-05 11:48:59 +00:00
| `name` | string | no | The name of the user who triggered pipelines |
| `username` | string | no | The username of the user who triggered pipelines |
2017-04-27 13:09:18 +00:00
| `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-08-17 13:23:58 +00:00
```
2017-03-01 17:39:40 +00:00
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/1/pipelines"
2016-08-17 13:23:58 +00:00
```
Example of response
```json
[
{
"id": 47,
"status": "pending",
"ref": "new-pipeline",
2017-01-30 11:11:58 +00:00
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a"
2016-08-17 13:23:58 +00:00
},
{
"id": 48,
"status": "pending",
"ref": "new-pipeline",
2017-01-30 11:11:58 +00:00
"sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a"
2016-08-17 13:23:58 +00:00
}
]
```
## Get a single pipeline
> [Introduced][ce-5837] in GitLab 8.11
```
GET /projects/:id/pipelines/:pipeline_id
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
2017-04-08 09:21:11 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
2016-08-17 13:23:58 +00:00
| `pipeline_id` | integer | yes | The ID of a pipeline |
```
2017-10-31 10:48:12 +00:00
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/1/pipelines/46"
2016-08-17 13:23:58 +00:00
```
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-10-13 11:24:09 +00:00
"web_url": "http://localhost:3000/root"
2016-08-17 13:23:58 +00: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 16:38:51 +00:00
"duration": null,
"coverage": "30.0"
2016-08-17 13:23:58 +00:00
}
```
2016-10-31 20:38:24 +00:00
## Create a new pipeline
> [Introduced][ce-7209] in GitLab 8.14
```
POST /projects/:id/pipeline
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
2017-04-08 09:21:11 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
2016-10-31 20:38:24 +00:00
| `ref` | string | yes | Reference to commit |
2018-06-01 13:52:24 +00:00
| `variables` | array | no | An array containing the variables available in the pipeline, matching the structure [{ 'key' => 'UPLOAD_TO_S3', 'value' => 'true' }] |
2016-10-31 20:38:24 +00:00
```
2017-03-01 17:39:40 +00:00
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/1/pipeline?ref=master"
2016-10-31 20:38:24 +00:00
```
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,
2016-11-25 16:38:51 +00:00
"duration": null,
2018-05-24 06:55:47 +00:00
"coverage": null,
"variables": []
2016-10-31 20:38:24 +00:00
}
```
2017-03-06 09:24:03 +00:00
## Retry jobs in a pipeline
2016-08-17 13:23:58 +00:00
> [Introduced][ce-5837] in GitLab 8.11
```
POST /projects/:id/pipelines/:pipeline_id/retry
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
2017-04-08 09:21:11 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
2016-08-17 13:23:58 +00:00
| `pipeline_id` | integer | yes | The ID of a pipeline |
```
2017-03-01 17:39:40 +00:00
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/1/pipelines/46/retry"
2016-08-17 13:23:58 +00:00
```
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-10-13 11:24:09 +00:00
"web_url": "http://localhost:3000/root"
2016-08-17 13:23:58 +00: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 16:38:51 +00:00
"duration": null,
"coverage": null
2016-08-17 13:23:58 +00:00
}
```
2017-04-08 08:54:00 +00:00
## Cancel a pipelines jobs
2016-08-17 13:23:58 +00:00
> [Introduced][ce-5837] in GitLab 8.11
```
POST /projects/:id/pipelines/:pipeline_id/cancel
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
2017-04-08 09:21:11 +00:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
2016-08-17 13:23:58 +00:00
| `pipeline_id` | integer | yes | The ID of a pipeline |
```
2017-03-01 17:39:40 +00:00
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/1/pipelines/46/cancel"
2016-08-17 13:23:58 +00:00
```
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-10-13 11:24:09 +00:00
"web_url": "http://localhost:3000/root"
2016-08-17 13:23:58 +00: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 16:38:51 +00:00
"duration": null,
"coverage": null
2016-08-17 13:23:58 +00:00
}
```
[ce-5837]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5837
2016-10-31 20:38:24 +00:00
[ce-7209]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7209