summaryrefslogtreecommitdiff
path: root/doc/ci/api/commits.md
blob: 871de7abcce18ccd03451140cca3b49c40aa08c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Commits API

**DEPRECATED**

Since GitLab 8.1, there is a new commit status API. Please see the [revised
documentation](../../api/commits.md#commit-status).

---

__Authentication is done by GitLab CI project token__

## Commits

### Retrieve all commits per project

Get list of commits per project

    GET /ci/commits

Parameters:

  * `project_id` (required) - The ID of a project
  * `project_token` (requires) - Project token
  * `page` (optional)
  * `per_page` (optional) - items per request (default is 20)

Returns:

```json
[{
  "id": 3,
  "ref": "master",
  "sha": "65617dfc36761baa1f46a7006f2a88916f7f56cf",
  "project_id": 2,
  "before_sha": "96906f2bceb04c7323f8514aa5ad8cb1313e2898",
  "created_at": "2014-11-05T09:46:35.247Z",
  "status": "success",
  "finished_at": "2014-11-05T09:46:44.254Z",
  "duration": 5.062692165374756,
  "git_commit_message": "wow\n",
  "git_author_name": "Administrator",
  "git_author_email": "admin@example.com",
  "builds": [{
    "id": 7,
    "project_id": 2,
    "ref": "master",
    "status": "success",
    "finished_at": "2014-11-05T09:46:44.254Z",
    "created_at": "2014-11-05T09:46:35.259Z",
    "updated_at": "2014-11-05T09:46:44.255Z",
    "sha": "65617dfc36761baa1f46a7006f2a88916f7f56cf",
    "started_at": "2014-11-05T09:46:39.192Z",
    "before_sha": "96906f2bceb04c7323f8514aa5ad8cb1313e2898",
    "runner_id": 1,
    "coverage": null,
    "commit_id": 3
  }]
}]
```

### Create commit

Inform GitLab CI about new commit you want it to build.

__If commit already exists in GitLab CI it will not be created__


    POST /ci/commits

Parameters:

  * `project_id` (required) - The ID of a project
  * `project_token` (requires) - Project token
  * `data` (required) -  Push data. For example see comment in `lib/api/commits.rb`

Returns:

```json
{
  "id": 3,
  "ref": "master",
  "sha": "65617dfc36761baa1f46a7006f2a88916f7f56cf",
  "project_id": 2,
  "before_sha": "96906f2bceb04c7323f8514aa5ad8cb1313e2898",
  "created_at": "2014-11-05T09:46:35.247Z",
  "status": "success",
  "finished_at": "2014-11-05T09:46:44.254Z",
  "duration": 5.062692165374756,
  "git_commit_message": "wow\n",
  "git_author_name": "Administrator",
  "git_author_email": "admin@example.com",
  "builds": [{
    "id": 7,
    "project_id": 2,
    "ref": "master",
    "status": "success",
    "finished_at": "2014-11-05T09:46:44.254Z",
    "created_at": "2014-11-05T09:46:35.259Z",
    "updated_at": "2014-11-05T09:46:44.255Z",
    "sha": "65617dfc36761baa1f46a7006f2a88916f7f56cf",
    "started_at": "2014-11-05T09:46:39.192Z",
    "before_sha": "96906f2bceb04c7323f8514aa5ad8cb1313e2898",
    "runner_id": 1,
    "coverage": null,
    "commit_id": 3
  }]
}
```