2017-05-18 04:49:03 -04:00
|
|
|
# System hooks API
|
2014-05-27 08:12:15 -04:00
|
|
|
|
2016-01-24 14:19:46 -05:00
|
|
|
All methods require administrator authorization.
|
2014-03-14 14:53:43 -04:00
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
The URL endpoint of the system hooks can also be configured using the UI in
|
2016-01-24 14:19:46 -05:00
|
|
|
the admin area under **Hooks** (`/admin/hooks`).
|
|
|
|
|
|
|
|
Read more about [system hooks](../system_hooks/system_hooks.md).
|
2014-03-14 14:53:43 -04:00
|
|
|
|
|
|
|
## List system hooks
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
Get a list of all system hooks.
|
2014-03-14 14:53:43 -04:00
|
|
|
|
|
|
|
```
|
|
|
|
GET /hooks
|
|
|
|
```
|
|
|
|
|
2016-01-24 14:19:46 -05:00
|
|
|
Example request:
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
```bash
|
2018-12-27 04:03:08 -05:00
|
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/hooks
|
2016-01-18 03:45:50 -05:00
|
|
|
```
|
2014-03-14 14:53:43 -04:00
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
Example response:
|
2014-03-14 14:53:43 -04:00
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
2016-10-19 10:08:30 -04:00
|
|
|
{
|
|
|
|
"id":1,
|
|
|
|
"url":"https://gitlab.example.com/hook",
|
|
|
|
"created_at":"2016-10-31T12:32:15.192Z",
|
|
|
|
"push_events":true,
|
|
|
|
"tag_push_events":false,
|
2017-11-23 10:45:00 -05:00
|
|
|
"merge_requests_events": true,
|
2018-08-14 14:55:55 -04:00
|
|
|
"repository_update_events": true,
|
2016-10-19 10:08:30 -04:00
|
|
|
"enable_ssl_verification":true
|
|
|
|
}
|
2014-03-14 14:53:43 -04:00
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
## Add new system hook
|
2014-03-14 14:53:43 -04:00
|
|
|
|
2016-01-24 14:19:46 -05:00
|
|
|
Add a new system hook.
|
|
|
|
|
2014-03-14 14:53:43 -04:00
|
|
|
```
|
|
|
|
POST /hooks
|
|
|
|
```
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ---- | -------- | ----------- |
|
|
|
|
| `url` | string | yes | The hook URL |
|
2016-11-02 08:24:24 -04:00
|
|
|
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
|
|
|
|
| `push_events` | boolean | no | When true, the hook will fire on push events |
|
|
|
|
| `tag_push_events` | boolean | no | When true, the hook will fire on new tags being pushed |
|
2017-11-23 15:36:58 -05:00
|
|
|
| `merge_requests_events` | boolean | no | Trigger hook on merge requests events |
|
2018-08-14 14:55:55 -04:00
|
|
|
| `repository_update_events` | boolean | no | Trigger hook on repository update events |
|
2016-11-02 08:24:24 -04:00
|
|
|
| `enable_ssl_verification` | boolean | no | Do SSL verification when triggering the hook |
|
2016-01-18 03:45:50 -05:00
|
|
|
|
2016-01-24 14:19:46 -05:00
|
|
|
Example request:
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
```bash
|
2018-12-27 04:03:08 -05:00
|
|
|
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/hooks?url=https://gitlab.example.com/hook"
|
2016-01-18 03:45:50 -05:00
|
|
|
```
|
2014-03-14 14:53:43 -04:00
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
2016-10-19 10:08:30 -04:00
|
|
|
{
|
|
|
|
"id":1,
|
|
|
|
"url":"https://gitlab.example.com/hook",
|
|
|
|
"created_at":"2016-10-31T12:32:15.192Z",
|
|
|
|
"push_events":true,
|
|
|
|
"tag_push_events":false,
|
2017-11-23 15:36:58 -05:00
|
|
|
"merge_requests_events": true,
|
2018-08-14 14:55:55 -04:00
|
|
|
"repository_update_events": true,
|
2016-10-19 10:08:30 -04:00
|
|
|
"enable_ssl_verification":true
|
|
|
|
}
|
2016-01-18 03:45:50 -05:00
|
|
|
]
|
|
|
|
```
|
2014-03-14 14:53:43 -04:00
|
|
|
|
|
|
|
## Test system hook
|
|
|
|
|
|
|
|
```
|
|
|
|
GET /hooks/:id
|
|
|
|
```
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ---- | -------- | ----------- |
|
|
|
|
| `id` | integer | yes | The ID of the hook |
|
2014-03-14 14:53:43 -04:00
|
|
|
|
2016-01-24 14:19:46 -05:00
|
|
|
Example request:
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
```bash
|
2018-12-27 04:03:08 -05:00
|
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/hooks/2
|
2016-01-18 03:45:50 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
2014-03-14 14:53:43 -04:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2016-01-18 03:45:50 -05:00
|
|
|
"project_id" : 1,
|
|
|
|
"owner_email" : "example@gitlabhq.com",
|
|
|
|
"owner_name" : "Someone",
|
|
|
|
"name" : "Ruby",
|
|
|
|
"path" : "ruby",
|
|
|
|
"event_name" : "project_create"
|
2014-03-14 14:53:43 -04:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Delete system hook
|
|
|
|
|
2016-11-24 12:28:52 -05:00
|
|
|
Deletes a system hook.
|
2016-01-24 14:19:46 -05:00
|
|
|
|
2014-03-14 14:53:43 -04:00
|
|
|
```
|
|
|
|
DELETE /hooks/:id
|
|
|
|
```
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ---- | -------- | ----------- |
|
|
|
|
| `id` | integer | yes | The ID of the hook |
|
|
|
|
|
2016-01-24 14:19:46 -05:00
|
|
|
Example request:
|
|
|
|
|
2016-01-18 03:45:50 -05:00
|
|
|
```bash
|
2018-12-27 04:03:08 -05:00
|
|
|
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/hooks/2
|
2019-07-14 21:04:35 -04:00
|
|
|
```
|