PageRenderTime 42ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/doc/api/builds.md

https://gitlab.com/demisxbar/gitlab-ce
Markdown | 421 lines | 368 code | 53 blank | 0 comment | 0 complexity | cd7809a42935885824d39426ee64e16d MD5 | raw file
  1. # Builds API
  2. ## List project builds
  3. Get a list of builds in a project.
  4. ```
  5. GET /projects/:id/builds
  6. ```
  7. | Attribute | Type | Required | Description |
  8. |-----------|---------|----------|---------------------|
  9. | `id` | integer | yes | The ID of a project |
  10. | `scope` | string **or** array of strings | no | The scope of builds to show, one or array of: `pending`, `running`, `failed`, `success`, `canceled`; showing all builds if none provided |
  11. ```
  12. curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds"
  13. ```
  14. Example of response
  15. ```json
  16. [
  17. {
  18. "commit": {
  19. "author_email": "admin@example.com",
  20. "author_name": "Administrator",
  21. "created_at": "2015-12-24T16:51:14.000+01:00",
  22. "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
  23. "message": "Test the CI integration.",
  24. "short_id": "0ff3ae19",
  25. "title": "Test the CI integration."
  26. },
  27. "coverage": null,
  28. "created_at": "2015-12-24T15:51:21.802Z",
  29. "artifacts_file": {
  30. "filename": "artifacts.zip",
  31. "size": 1000
  32. },
  33. "finished_at": "2015-12-24T17:54:27.895Z",
  34. "id": 7,
  35. "name": "teaspoon",
  36. "ref": "master",
  37. "runner": null,
  38. "stage": "test",
  39. "started_at": "2015-12-24T17:54:27.722Z",
  40. "status": "failed",
  41. "tag": false,
  42. "user": {
  43. "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
  44. "bio": null,
  45. "created_at": "2015-12-21T13:14:24.077Z",
  46. "id": 1,
  47. "is_admin": true,
  48. "linkedin": "",
  49. "name": "Administrator",
  50. "skype": "",
  51. "state": "active",
  52. "twitter": "",
  53. "username": "root",
  54. "web_url": "http://gitlab.dev/u/root",
  55. "website_url": ""
  56. }
  57. },
  58. {
  59. "commit": {
  60. "author_email": "admin@example.com",
  61. "author_name": "Administrator",
  62. "created_at": "2015-12-24T16:51:14.000+01:00",
  63. "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
  64. "message": "Test the CI integration.",
  65. "short_id": "0ff3ae19",
  66. "title": "Test the CI integration."
  67. },
  68. "coverage": null,
  69. "created_at": "2015-12-24T15:51:21.727Z",
  70. "artifacts_file": null,
  71. "finished_at": "2015-12-24T17:54:24.921Z",
  72. "id": 6,
  73. "name": "spinach:other",
  74. "ref": "master",
  75. "runner": null,
  76. "stage": "test",
  77. "started_at": "2015-12-24T17:54:24.729Z",
  78. "status": "failed",
  79. "tag": false,
  80. "user": {
  81. "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
  82. "bio": null,
  83. "created_at": "2015-12-21T13:14:24.077Z",
  84. "id": 1,
  85. "is_admin": true,
  86. "linkedin": "",
  87. "name": "Administrator",
  88. "skype": "",
  89. "state": "active",
  90. "twitter": "",
  91. "username": "root",
  92. "web_url": "http://gitlab.dev/u/root",
  93. "website_url": ""
  94. }
  95. }
  96. ]
  97. ```
  98. ## List commit builds
  99. Get a list of builds for specific commit in a project.
  100. ```
  101. GET /projects/:id/repository/commits/:sha/builds
  102. ```
  103. | Attribute | Type | Required | Description |
  104. |-----------|---------|----------|---------------------|
  105. | `id` | integer | yes | The ID of a project |
  106. | `sha` | string | yes | The SHA id of a commit |
  107. | `scope` | string **or** array of strings | no | The scope of builds to show, one or array of: `pending`, `running`, `failed`, `success`, `canceled`; showing all builds if none provided |
  108. ```
  109. curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/repository/commits/0ff3ae198f8601a285adcf5c0fff204ee6fba5fd/builds"
  110. ```
  111. Example of response
  112. ```json
  113. [
  114. {
  115. "commit": {
  116. "author_email": "admin@example.com",
  117. "author_name": "Administrator",
  118. "created_at": "2015-12-24T16:51:14.000+01:00",
  119. "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
  120. "message": "Test the CI integration.",
  121. "short_id": "0ff3ae19",
  122. "title": "Test the CI integration."
  123. },
  124. "coverage": null,
  125. "created_at": "2016-01-11T10:13:33.506Z",
  126. "artifacts_file": null,
  127. "finished_at": "2016-01-11T10:14:09.526Z",
  128. "id": 69,
  129. "name": "rubocop",
  130. "ref": "master",
  131. "runner": null,
  132. "stage": "test",
  133. "started_at": null,
  134. "status": "canceled",
  135. "tag": false,
  136. "user": null
  137. },
  138. {
  139. "commit": {
  140. "author_email": "admin@example.com",
  141. "author_name": "Administrator",
  142. "created_at": "2015-12-24T16:51:14.000+01:00",
  143. "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
  144. "message": "Test the CI integration.",
  145. "short_id": "0ff3ae19",
  146. "title": "Test the CI integration."
  147. },
  148. "coverage": null,
  149. "created_at": "2015-12-24T15:51:21.957Z",
  150. "artifacts_file": null,
  151. "finished_at": "2015-12-24T17:54:33.913Z",
  152. "id": 9,
  153. "name": "brakeman",
  154. "ref": "master",
  155. "runner": null,
  156. "stage": "test",
  157. "started_at": "2015-12-24T17:54:33.727Z",
  158. "status": "failed",
  159. "tag": false,
  160. "user": {
  161. "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
  162. "bio": null,
  163. "created_at": "2015-12-21T13:14:24.077Z",
  164. "id": 1,
  165. "is_admin": true,
  166. "linkedin": "",
  167. "name": "Administrator",
  168. "skype": "",
  169. "state": "active",
  170. "twitter": "",
  171. "username": "root",
  172. "web_url": "http://gitlab.dev/u/root",
  173. "website_url": ""
  174. }
  175. }
  176. ]
  177. ```
  178. ## Get a single build
  179. Get a single build of a project
  180. ```
  181. GET /projects/:id/builds/:build_id
  182. ```
  183. | Attribute | Type | Required | Description |
  184. |------------|---------|----------|---------------------|
  185. | `id` | integer | yes | The ID of a project |
  186. | `build_id` | integer | yes | The ID of a build |
  187. ```
  188. curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/8"
  189. ```
  190. Example of response
  191. ```json
  192. {
  193. "commit": {
  194. "author_email": "admin@example.com",
  195. "author_name": "Administrator",
  196. "created_at": "2015-12-24T16:51:14.000+01:00",
  197. "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
  198. "message": "Test the CI integration.",
  199. "short_id": "0ff3ae19",
  200. "title": "Test the CI integration."
  201. },
  202. "coverage": null,
  203. "created_at": "2015-12-24T15:51:21.880Z",
  204. "artifacts_file": null,
  205. "finished_at": "2015-12-24T17:54:31.198Z",
  206. "id": 8,
  207. "name": "rubocop",
  208. "ref": "master",
  209. "runner": null,
  210. "stage": "test",
  211. "started_at": "2015-12-24T17:54:30.733Z",
  212. "status": "failed",
  213. "tag": false,
  214. "user": {
  215. "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
  216. "bio": null,
  217. "created_at": "2015-12-21T13:14:24.077Z",
  218. "id": 1,
  219. "is_admin": true,
  220. "linkedin": "",
  221. "name": "Administrator",
  222. "skype": "",
  223. "state": "active",
  224. "twitter": "",
  225. "username": "root",
  226. "web_url": "http://gitlab.dev/u/root",
  227. "website_url": ""
  228. }
  229. }
  230. ```
  231. ## Get build artifacts
  232. > [Introduced][ce-2893] in GitLab 8.5
  233. Get build artifacts of a project
  234. ```
  235. GET /projects/:id/builds/:build_id/artifacts
  236. ```
  237. | Attribute | Type | Required | Description |
  238. |------------|---------|----------|---------------------|
  239. | `id` | integer | yes | The ID of a project |
  240. | `build_id` | integer | yes | The ID of a build |
  241. ```
  242. curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/8/artifacts"
  243. ```
  244. Response:
  245. | Status | Description |
  246. |-----------|---------------------------------|
  247. | 200 | Serves the artifacts file |
  248. | 404 | Build not found or no artifacts |
  249. [ce-2893]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/2893
  250. ## Cancel a build
  251. Cancel a single build of a project
  252. ```
  253. POST /projects/:id/builds/:build_id/cancel
  254. ```
  255. | Attribute | Type | Required | Description |
  256. |------------|---------|----------|---------------------|
  257. | `id` | integer | yes | The ID of a project |
  258. | `build_id` | integer | yes | The ID of a build |
  259. ```
  260. curl -X POST -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/cancel"
  261. ```
  262. Example of response
  263. ```json
  264. {
  265. "commit": {
  266. "author_email": "admin@example.com",
  267. "author_name": "Administrator",
  268. "created_at": "2015-12-24T16:51:14.000+01:00",
  269. "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
  270. "message": "Test the CI integration.",
  271. "short_id": "0ff3ae19",
  272. "title": "Test the CI integration."
  273. },
  274. "coverage": null,
  275. "created_at": "2016-01-11T10:13:33.506Z",
  276. "artifacts_file": null,
  277. "finished_at": "2016-01-11T10:14:09.526Z",
  278. "id": 69,
  279. "name": "rubocop",
  280. "ref": "master",
  281. "runner": null,
  282. "stage": "test",
  283. "started_at": null,
  284. "status": "canceled",
  285. "tag": false,
  286. "user": null
  287. }
  288. ```
  289. ## Retry a build
  290. Retry a single build of a project
  291. ```
  292. POST /projects/:id/builds/:build_id/retry
  293. ```
  294. | Attribute | Type | Required | Description |
  295. |------------|---------|----------|---------------------|
  296. | `id` | integer | yes | The ID of a project |
  297. | `build_id` | integer | yes | The ID of a build |
  298. ```
  299. curl -X POST -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/retry"
  300. ```
  301. Example of response
  302. ```json
  303. {
  304. "commit": {
  305. "author_email": "admin@example.com",
  306. "author_name": "Administrator",
  307. "created_at": "2015-12-24T16:51:14.000+01:00",
  308. "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
  309. "message": "Test the CI integration.",
  310. "short_id": "0ff3ae19",
  311. "title": "Test the CI integration."
  312. },
  313. "coverage": null,
  314. "created_at": "2016-01-11T10:13:33.506Z",
  315. "artifacts_file": null,
  316. "finished_at": null,
  317. "id": 69,
  318. "name": "rubocop",
  319. "ref": "master",
  320. "runner": null,
  321. "stage": "test",
  322. "started_at": null,
  323. "status": "pending",
  324. "tag": false,
  325. "user": null
  326. }
  327. ```
  328. ## Erase a build
  329. Erase a single build of a project (remove build artifacts and a build trace)
  330. ```
  331. POST /projects/:id/builds/:build_id/erase
  332. ```
  333. Parameters
  334. | Attribute | Type | required | Description |
  335. |-------------|---------|----------|---------------------|
  336. | `id` | integer | yes | The ID of a project |
  337. | `build_id` | integer | yes | The ID of a build |
  338. Example of request
  339. ```
  340. curl -X POST -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/erase"
  341. ```
  342. Example of response
  343. ```json
  344. {
  345. "commit": {
  346. "author_email": "admin@example.com",
  347. "author_name": "Administrator",
  348. "created_at": "2015-12-24T16:51:14.000+01:00",
  349. "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
  350. "message": "Test the CI integration.",
  351. "short_id": "0ff3ae19",
  352. "title": "Test the CI integration."
  353. },
  354. "coverage": null,
  355. "download_url": null,
  356. "id": 69,
  357. "name": "rubocop",
  358. "ref": "master",
  359. "runner": null,
  360. "stage": "test",
  361. "created_at": "2016-01-11T10:13:33.506Z",
  362. "started_at": "2016-01-11T10:13:33.506Z",
  363. "finished_at": "2016-01-11T10:15:10.506Z",
  364. "status": "failed",
  365. "tag": false,
  366. "user": null
  367. }
  368. ```