BigW Consortium Gitlab

builds.md 16 KB
Newer Older
Tomasz Maczukin committed
1 2 3 4 5 6 7 8 9 10
# Builds API

## List project builds

Get a list of builds in a project.

```
GET /projects/:id/builds
```

Tomasz Maczukin committed
11
| Attribute | Type    | Required | Description         |
12
|-----------|---------|----------|---------------------|
13
| `id`      | integer | yes      | The ID of a project |
14
| `scope`   | string **or** array of strings | no | The scope of builds to show, one or array of: `created`, `pending`, `running`, `failed`, `success`, `canceled`, `skipped`; showing all builds if none provided |
15 16

```
17
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" 'https://gitlab.example.com/api/v3/projects/1/builds?scope%5B0%5D=pending&scope%5B1%5D=running'
18 19
```

20
Example of response
Tomasz Maczukin committed
21 22 23

```json
[
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
  {
    "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,
    "created_at": "2015-12-24T15:51:21.802Z",
    "artifacts_file": {
      "filename": "artifacts.zip",
      "size": 1000
    },
    "finished_at": "2015-12-24T17:54:27.895Z",
    "id": 7,
    "name": "teaspoon",
43 44 45 46 47 48
    "pipeline": {
      "id": 6,
      "ref": "master",
      "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
      "status": "pending"
    }
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
    "ref": "master",
    "runner": null,
    "stage": "test",
    "started_at": "2015-12-24T17:54:27.722Z",
    "status": "failed",
    "tag": false,
    "user": {
      "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "bio": null,
      "created_at": "2015-12-21T13:14:24.077Z",
      "id": 1,
      "is_admin": true,
      "linkedin": "",
      "name": "Administrator",
      "skype": "",
      "state": "active",
      "twitter": "",
      "username": "root",
67
      "web_url": "http://gitlab.dev/root",
68 69 70 71 72 73 74 75 76 77 78 79
      "website_url": ""
    }
  },
  {
    "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."
Tomasz Maczukin committed
80
    },
81 82 83 84 85 86
    "coverage": null,
    "created_at": "2015-12-24T15:51:21.727Z",
    "artifacts_file": null,
    "finished_at": "2015-12-24T17:54:24.921Z",
    "id": 6,
    "name": "spinach:other",
87 88 89 90 91 92
    "pipeline": {
      "id": 6,
      "ref": "master",
      "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
      "status": "pending"
    }
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
    "ref": "master",
    "runner": null,
    "stage": "test",
    "started_at": "2015-12-24T17:54:24.729Z",
    "status": "failed",
    "tag": false,
    "user": {
      "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "bio": null,
      "created_at": "2015-12-21T13:14:24.077Z",
      "id": 1,
      "is_admin": true,
      "linkedin": "",
      "name": "Administrator",
      "skype": "",
      "state": "active",
      "twitter": "",
      "username": "root",
111
      "web_url": "http://gitlab.dev/root",
112
      "website_url": ""
Tomasz Maczukin committed
113
    }
114
  }
Tomasz Maczukin committed
115 116 117 118 119 120 121
]
```

## List commit builds

Get a list of builds for specific commit in a project.

122 123 124 125 126
This endpoint will return all builds, from all pipelines for a given commit.
If the commit SHA is not found, it will respond with 404, otherwise it will
return an array of builds (an empty array if there are no builds for this
particular commit).

Tomasz Maczukin committed
127
```
128
GET /projects/:id/repository/commits/:sha/builds
Tomasz Maczukin committed
129 130
```

Tomasz Maczukin committed
131
| Attribute | Type    | Required | Description         |
132
|-----------|---------|----------|---------------------|
133 134
| `id`      | integer | yes      | The ID of a project |
| `sha`     | string  | yes      | The SHA id of a commit |
135
| `scope`   | string **or** array of strings | no | The scope of builds to show, one or array of: `created`, `pending`, `running`, `failed`, `success`, `canceled`, `skipped`; showing all builds if none provided |
136 137

```
138
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" 'https://gitlab.example.com/api/v3/projects/1/repository/commits/0ff3ae198f8601a285adcf5c0fff204ee6fba5fd/builds?scope%5B0%5D=pending&scope%5B1%5D=running'
139 140
```

141
Example of response
Tomasz Maczukin committed
142 143

```json
144
[
145 146 147 148 149 150 151 152 153
  {
    "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."
Tomasz Maczukin committed
154
    },
155 156 157 158 159 160
    "coverage": null,
    "created_at": "2016-01-11T10:13:33.506Z",
    "artifacts_file": null,
    "finished_at": "2016-01-11T10:14:09.526Z",
    "id": 69,
    "name": "rubocop",
161 162 163 164 165 166
    "pipeline": {
      "id": 6,
      "ref": "master",
      "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
      "status": "pending"
    }
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
    "ref": "master",
    "runner": null,
    "stage": "test",
    "started_at": null,
    "status": "canceled",
    "tag": false,
    "user": null
  },
  {
    "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,
    "created_at": "2015-12-24T15:51:21.957Z",
    "artifacts_file": null,
    "finished_at": "2015-12-24T17:54:33.913Z",
    "id": 9,
    "name": "brakeman",
191 192 193 194 195 196
    "pipeline": {
      "id": 6,
      "ref": "master",
      "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
      "status": "pending"
    }
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
    "ref": "master",
    "runner": null,
    "stage": "test",
    "started_at": "2015-12-24T17:54:33.727Z",
    "status": "failed",
    "tag": false,
    "user": {
      "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "bio": null,
      "created_at": "2015-12-21T13:14:24.077Z",
      "id": 1,
      "is_admin": true,
      "linkedin": "",
      "name": "Administrator",
      "skype": "",
      "state": "active",
      "twitter": "",
      "username": "root",
215
      "web_url": "http://gitlab.dev/root",
216
      "website_url": ""
Tomasz Maczukin committed
217
    }
218
  }
Tomasz Maczukin committed
219
]
220 221 222
```

## Get a single build
Tomasz Maczukin committed
223 224 225 226 227 228 229

Get a single build of a project

```
GET /projects/:id/builds/:build_id
```

Tomasz Maczukin committed
230
| Attribute  | Type    | Required | Description         |
231 232 233
|------------|---------|----------|---------------------|
| `id`       | integer | yes      | The ID of a project |
| `build_id` | integer | yes      | The ID of a build   |
234 235

```
236
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/8"
237 238
```

239
Example of response
Tomasz Maczukin committed
240 241 242

```json
{
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
  "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,
  "created_at": "2015-12-24T15:51:21.880Z",
  "artifacts_file": null,
  "finished_at": "2015-12-24T17:54:31.198Z",
  "id": 8,
  "name": "rubocop",
258 259 260 261 262 263
  "pipeline": {
    "id": 6,
    "ref": "master",
    "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
    "status": "pending"
  }
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
  "ref": "master",
  "runner": null,
  "stage": "test",
  "started_at": "2015-12-24T17:54:30.733Z",
  "status": "failed",
  "tag": false,
  "user": {
    "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
    "bio": null,
    "created_at": "2015-12-21T13:14:24.077Z",
    "id": 1,
    "is_admin": true,
    "linkedin": "",
    "name": "Administrator",
    "skype": "",
    "state": "active",
    "twitter": "",
    "username": "root",
282
    "web_url": "http://gitlab.dev/root",
283 284
    "website_url": ""
  }
Tomasz Maczukin committed
285 286 287
}
```

Kamil Trzcinski committed
288
## Get build artifacts
289

290 291
> [Introduced][ce-2893] in GitLab 8.5

Kamil Trzcinski committed
292
Get build artifacts of a project
293 294 295 296 297

```
GET /projects/:id/builds/:build_id/artifacts
```

298 299 300 301
| Attribute  | Type    | Required | Description         |
|------------|---------|----------|---------------------|
| `id`       | integer | yes      | The ID of a project |
| `build_id` | integer | yes      | The ID of a build   |
302 303

```
304
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/8/artifacts"
305 306
```

307
Response:
308 309 310 311 312 313

| Status    | Description                     |
|-----------|---------------------------------|
| 200       | Serves the artifacts file       |
| 404       | Build not found or no artifacts |

314 315
[ce-2893]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/2893

316 317 318 319 320 321 322 323
## Download the artifacts file

> [Introduced][ce-5347] in GitLab 8.10.

Download the artifacts file from the given reference name and job provided the
build finished successfully.

```
324
GET /projects/:id/builds/artifacts/:ref_name/download?job=name
325 326 327 328 329 330 331 332 333 334 335 336 337
```

Parameters

| Attribute   | Type    | Required | Description               |
|-------------|---------|----------|-------------------------- |
| `id`        | integer | yes      | The ID of a project       |
| `ref_name`  | string  | yes      | The ref from a repository |
| `job`       | string  | yes      | The name of the job       |

Example request:

```
338
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/artifacts/master/download?job=test"
339 340 341 342 343 344 345 346 347 348 349
```

Example response:

| Status    | Description                     |
|-----------|---------------------------------|
| 200       | Serves the artifacts file       |
| 404       | Build not found or no artifacts |

[ce-5347]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5347

350 351 352 353 354 355 356 357 358 359 360 361 362 363
## Get a trace file

Get a trace of a specific build of a project

```
GET /projects/:id/builds/:build_id/trace
```

| Attribute  | Type    | Required | Description         |
|------------|---------|----------|---------------------|
| id         | integer | yes      | The ID of a project |
| build_id   | integer | yes      | The ID of a build   |

```
364
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/8/trace"
365 366 367 368 369 370 371 372 373
```

Response:

| Status    | Description                       |
|-----------|-----------------------------------|
| 200       | Serves the trace file             |
| 404       | Build not found or no trace file  |

Tomasz Maczukin committed
374 375 376 377 378 379 380 381
## Cancel a build

Cancel a single build of a project

```
POST /projects/:id/builds/:build_id/cancel
```

Tomasz Maczukin committed
382
| Attribute  | Type    | Required | Description         |
383 384 385
|------------|---------|----------|---------------------|
| `id`       | integer | yes      | The ID of a project |
| `build_id` | integer | yes      | The ID of a build   |
386 387

```
388
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/cancel"
389
```
Tomasz Maczukin committed
390

391
Example of response
Tomasz Maczukin committed
392 393 394

```json
{
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
  "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,
  "created_at": "2016-01-11T10:13:33.506Z",
  "artifacts_file": null,
  "finished_at": "2016-01-11T10:14:09.526Z",
  "id": 69,
  "name": "rubocop",
  "ref": "master",
  "runner": null,
  "stage": "test",
  "started_at": null,
  "status": "canceled",
  "tag": false,
  "user": null
Tomasz Maczukin committed
417 418 419 420 421 422 423 424 425 426 427
}
```

## Retry a build

Retry a single build of a project

```
POST /projects/:id/builds/:build_id/retry
```

Tomasz Maczukin committed
428
| Attribute  | Type    | Required | Description         |
429 430 431
|------------|---------|----------|---------------------|
| `id`       | integer | yes      | The ID of a project |
| `build_id` | integer | yes      | The ID of a build   |
432 433

```
434
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/retry"
435
```
Tomasz Maczukin committed
436

437
Example of response
Tomasz Maczukin committed
438 439 440

```json
{
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
  "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,
  "created_at": "2016-01-11T10:13:33.506Z",
  "artifacts_file": null,
  "finished_at": null,
  "id": 69,
  "name": "rubocop",
  "ref": "master",
  "runner": null,
  "stage": "test",
  "started_at": null,
  "status": "pending",
  "tag": false,
  "user": null
Tomasz Maczukin committed
463 464
}
```
465 466 467 468 469 470

## Erase a build

Erase a single build of a project (remove build artifacts and a build trace)

```
471
POST /projects/:id/builds/:build_id/erase
472 473 474 475
```

Parameters

476
| Attribute   | Type    | Required | Description         |
477
|-------------|---------|----------|---------------------|
478
| `id`        | integer | yes      | The ID of a project |
479
| `build_id`  | integer | yes      | The ID of a build   |
480 481 482 483

Example of request

```
484
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/erase"
485 486 487 488 489 490
```

Example of response

```json
{
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512
  "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,
  "download_url": null,
  "id": 69,
  "name": "rubocop",
  "ref": "master",
  "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",
  "status": "failed",
  "tag": false,
  "user": null
513 514
}
```
515 516 517

## Keep artifacts

518
Prevents artifacts from being deleted when expiration is set.
519 520 521 522 523 524 525

```
POST /projects/:id/builds/:build_id/artifacts/keep
```

Parameters

526
| Attribute   | Type    | Required | Description         |
527 528 529 530
|-------------|---------|----------|---------------------|
| `id`        | integer | yes      | The ID of a project |
| `build_id`  | integer | yes      | The ID of a build   |

531
Example request:
532 533

```
534
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/artifacts/keep"
535 536
```

537
Example response:
538 539 540

```json
{
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562
  "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,
  "download_url": null,
  "id": 69,
  "name": "rubocop",
  "ref": "master",
  "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",
  "status": "failed",
  "tag": false,
  "user": null
563 564
}
```
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610

## Play a build

Triggers a manual action to start a build.

```
POST /projects/:id/builds/:build_id/play
```

| Attribute  | Type    | Required | Description         |
|------------|---------|----------|---------------------|
| `id`       | integer | yes      | The ID of a project |
| `build_id` | integer | yes      | The ID of a build   |

```
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/play"
```

Example of response

```json
{
  "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,
  "created_at": "2016-01-11T10:13:33.506Z",
  "artifacts_file": null,
  "finished_at": null,
  "id": 69,
  "name": "rubocop",
  "ref": "master",
  "runner": null,
  "stage": "test",
  "started_at": null,
  "status": "started",
  "tag": false,
  "user": null
}
```