2020-10-24 23:57:45 +05:30
---
stage: Create
group: Ecosystem
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
---
2017-08-17 22:00:37 +05:30
2020-10-24 23:57:45 +05:30
# Webhooks
2018-11-18 11:00:15 +05:30
2017-08-17 22:00:37 +05:30
Project webhooks allow you to trigger a URL if for example new code is pushed or
a new issue is created. You can configure webhooks to listen for specific events
like pushes, issues or merge requests. GitLab will send a POST request with data
to the webhook URL.
2019-07-07 11:18:12 +05:30
In most cases, you'll need to set up your own [webhook receiver ](#example-webhook-receiver )
to receive information from GitLab, and send it to another app, according to your needs.
2019-09-30 21:07:59 +05:30
We already have a [built-in receiver ](slack.md )
2019-07-07 11:18:12 +05:30
for sending [Slack ](https://api.slack.com/incoming-webhooks ) notifications _per project_ .
## Overview
[Webhooks ](https://en.wikipedia.org/wiki/Webhook ) are "_user-defined HTTP
callbacks_". They are usually triggered by some
event, such as pushing code to a repository or a comment being posted to a blog.
When that event occurs, the source app makes an HTTP request to the URI
configured for the webhook. The action taken may be anything.
Common uses are to trigger builds with continuous integration systems or to
notify bug tracking systems.
2017-08-17 22:00:37 +05:30
Webhooks can be used to update an external issue tracker, trigger CI jobs,
update a backup mirror, or even deploy to your production server.
2019-07-07 11:18:12 +05:30
They are available **per project** for GitLab Community Edition,
and **per project and per group** for **GitLab Enterprise Edition** .
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
Navigate to the webhooks page by going to your project's
2020-04-08 14:13:33 +05:30
**Settings ➔ Webhooks**.
2017-08-17 22:00:37 +05:30
2020-04-08 14:13:33 +05:30
NOTE: **Note:**
2020-10-24 23:57:45 +05:30
On GitLab.com, the [maximum number of webhooks and their size ](../../../user/gitlab_com/index.md#webhooks ) per project, and per group, is limited.
## Version history
Starting from GitLab 8.5:
- the `repository` key is deprecated in favor of the `project` key
- the `project.ssh_url` key is deprecated in favor of the `project.git_ssh_url` key
- the `project.http_url` key is deprecated in favor of the `project.git_http_url` key
Starting from GitLab 11.1, the logs of webhooks are automatically removed after
one month.
Starting from GitLab 11.2:
- The `description` field for issues, merge requests, comments, and wiki pages
is rewritten so that simple Markdown image references (like
`![](/uploads/...)` ) have their target URL changed to an absolute URL. See
[image URL rewriting ](#image-url-rewriting ) for more details.
2020-01-01 13:55:28 +05:30
2019-07-07 11:18:12 +05:30
## Use-cases
- You can set up a webhook in GitLab to send a notification to
[Slack ](https://api.slack.com/incoming-webhooks ) every time a job fails.
- You can [integrate with Twilio to be notified via SMS ](https://www.datadoghq.com/blog/send-alerts-sms-customizable-webhooks-twilio/ )
every time an issue is created for a specific project or group within GitLab
2019-12-21 20:55:43 +05:30
- You can use them to [automatically assign labels to merge requests ](https://about.gitlab.com/blog/2016/08/19/applying-gitlab-labels-automatically/ ).
2019-07-07 11:18:12 +05:30
2017-08-17 22:00:37 +05:30
## Webhook endpoint tips
If you are writing your own endpoint (web server) that will receive
GitLab webhooks keep in mind the following things:
2019-10-12 21:52:04 +05:30
- Your endpoint should send its HTTP response as fast as possible. If
you wait too long, GitLab may decide the hook failed and retry it.
- Your endpoint should ALWAYS return a valid HTTP response. If you do
not do this then GitLab will think the hook failed and retry it.
Most HTTP libraries take care of this for you automatically but if
you are writing a low-level hook this is important to remember.
- GitLab ignores the HTTP status code returned by your endpoint.
2017-08-17 22:00:37 +05:30
## Secret token
If you specify a secret token, it will be sent with the hook request in the
`X-Gitlab-Token` HTTP header. Your webhook endpoint can check that to verify
that the request is legitimate.
## SSL verification
By default, the SSL certificate of the webhook endpoint is verified based on
an internal list of Certificate Authorities, which means the certificate cannot
be self-signed.
You can turn this off in the webhook settings in your GitLab projects.
![SSL Verification ](img/webhooks_ssl.png )
2018-11-20 20:47:30 +05:30
## Branch filtering
2020-06-23 00:09:42 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/20338) in GitLab 11.3.
2018-11-20 20:47:30 +05:30
Push events can be filtered by branch using a branch name or wildcard pattern
to limit which push events are sent to your webhook endpoint. By default the
field is blank causing all push events to be sent to your webhook endpoint.
2017-08-17 22:00:37 +05:30
## Events
Below are described the supported events.
### Push events
Triggered when you push to the repository except when pushing tags.
2019-12-04 20:38:33 +05:30
NOTE: **Note:**
When more than 20 commits are pushed at once, the `commits` webhook
attribute will only contain the first 20 for performance reasons. Loading
detailed commit data is expensive. Note that despite only 20 commits being
present in the `commits` attribute, the `total_commits_count` attribute will
contain the actual total.
2018-03-17 18:26:18 +05:30
2019-12-21 20:55:43 +05:30
Also, if a single push includes changes for more than three (by default, depending on
[`push_event_hooks_limit` setting ](../../../api/settings.md#list-of-settings-that-can-be-accessed-via-api-calls )) branches, this hook won't be executed.
2017-08-17 22:00:37 +05:30
**Request header**:
2020-03-13 15:44:24 +05:30
```plaintext
2017-08-17 22:00:37 +05:30
X-Gitlab-Event: Push Hook
```
**Request body:**
```json
{
"object_kind": "push",
"before": "95790bf891e76fee5e1747ab589903a6a1f80f22",
"after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"ref": "refs/heads/master",
"checkout_sha": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"user_id": 4,
"user_name": "John Smith",
2017-09-10 17:25:29 +05:30
"user_username": "jsmith",
2017-08-17 22:00:37 +05:30
"user_email": "john@example.com",
"user_avatar": "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80",
"project_id": 15,
"project":{
2018-03-17 18:26:18 +05:30
"id": 15,
2017-08-17 22:00:37 +05:30
"name":"Diaspora",
"description":"",
"web_url":"http://example.com/mike/diaspora",
"avatar_url":null,
"git_ssh_url":"git@example.com:mike/diaspora.git",
"git_http_url":"http://example.com/mike/diaspora.git",
"namespace":"Mike",
"visibility_level":0,
"path_with_namespace":"mike/diaspora",
"default_branch":"master",
"homepage":"http://example.com/mike/diaspora",
"url":"git@example.com:mike/diaspora.git",
"ssh_url":"git@example.com:mike/diaspora.git",
"http_url":"http://example.com/mike/diaspora.git"
},
"repository":{
"name": "Diaspora",
"url": "git@example.com:mike/diaspora.git",
"description": "",
"homepage": "http://example.com/mike/diaspora",
"git_http_url":"http://example.com/mike/diaspora.git",
"git_ssh_url":"git@example.com:mike/diaspora.git",
"visibility_level":0
},
"commits": [
{
"id": "b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327",
2020-04-08 14:13:33 +05:30
"message": "Update Catalan translation to e38cb41.\n\nSee https://gitlab.com/gitlab-org/gitlab for more information",
"title": "Update Catalan translation to e38cb41.",
2017-08-17 22:00:37 +05:30
"timestamp": "2011-12-12T14:27:31+02:00",
"url": "http://example.com/mike/diaspora/commit/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327",
"author": {
"name": "Jordi Mallach",
"email": "jordi@softcatala.org"
},
"added": ["CHANGELOG"],
"modified": ["app/controller/application.rb"],
"removed": []
},
{
"id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"message": "fixed readme",
2020-04-08 14:13:33 +05:30
"title": "fixed readme",
2017-08-17 22:00:37 +05:30
"timestamp": "2012-01-03T23:36:29+02:00",
"url": "http://example.com/mike/diaspora/commit/da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"author": {
"name": "GitLab dev user",
"email": "gitlabdev@dv6700.(none)"
},
"added": ["CHANGELOG"],
"modified": ["app/controller/application.rb"],
"removed": []
}
],
"total_commits_count": 4
}
```
### Tag events
Triggered when you create (or delete) tags to the repository.
2019-12-21 20:55:43 +05:30
NOTE: **Note:**
If a single push includes changes for more than three (by default, depending on
[`push_event_hooks_limit` setting ](../../../api/settings.md#list-of-settings-that-can-be-accessed-via-api-calls )) tags, this hook won't be executed.
2017-08-17 22:00:37 +05:30
**Request header**:
2020-03-13 15:44:24 +05:30
```plaintext
2017-08-17 22:00:37 +05:30
X-Gitlab-Event: Tag Push Hook
```
**Request body:**
```json
{
"object_kind": "tag_push",
"before": "0000000000000000000000000000000000000000",
"after": "82b3d5ae55f7080f1e6022629cdb57bfae7cccc7",
"ref": "refs/tags/v1.0.0",
"checkout_sha": "82b3d5ae55f7080f1e6022629cdb57bfae7cccc7",
"user_id": 1,
"user_name": "John Smith",
"user_avatar": "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80",
"project_id": 1,
"project":{
2018-03-17 18:26:18 +05:30
"id": 1,
2017-08-17 22:00:37 +05:30
"name":"Example",
"description":"",
"web_url":"http://example.com/jsmith/example",
"avatar_url":null,
"git_ssh_url":"git@example.com:jsmith/example.git",
"git_http_url":"http://example.com/jsmith/example.git",
"namespace":"Jsmith",
"visibility_level":0,
"path_with_namespace":"jsmith/example",
"default_branch":"master",
"homepage":"http://example.com/jsmith/example",
"url":"git@example.com:jsmith/example.git",
"ssh_url":"git@example.com:jsmith/example.git",
"http_url":"http://example.com/jsmith/example.git"
},
"repository":{
"name": "Example",
"url": "ssh://git@example.com/jsmith/example.git",
"description": "",
"homepage": "http://example.com/jsmith/example",
"git_http_url":"http://example.com/jsmith/example.git",
"git_ssh_url":"git@example.com:jsmith/example.git",
"visibility_level":0
},
"commits": [],
"total_commits_count": 0
}
```
2020-04-22 19:07:51 +05:30
### Issue events
2017-08-17 22:00:37 +05:30
Triggered when a new issue is created or an existing issue was updated/closed/reopened.
**Request header**:
2020-03-13 15:44:24 +05:30
```plaintext
2017-08-17 22:00:37 +05:30
X-Gitlab-Event: Issue Hook
```
**Request body:**
```json
{
"object_kind": "issue",
2020-04-22 19:07:51 +05:30
"event_type": "issue",
2017-08-17 22:00:37 +05:30
"user": {
"name": "Administrator",
"username": "root",
2020-04-22 19:07:51 +05:30
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon",
"email": "admin@example.com"
2017-08-17 22:00:37 +05:30
},
2018-03-17 18:26:18 +05:30
"project": {
"id": 1,
2017-08-17 22:00:37 +05:30
"name":"Gitlab Test",
"description":"Aut reprehenderit ut est.",
"web_url":"http://example.com/gitlabhq/gitlab-test",
"avatar_url":null,
"git_ssh_url":"git@example.com:gitlabhq/gitlab-test.git",
"git_http_url":"http://example.com/gitlabhq/gitlab-test.git",
"namespace":"GitlabHQ",
"visibility_level":20,
"path_with_namespace":"gitlabhq/gitlab-test",
"default_branch":"master",
2020-04-22 19:07:51 +05:30
"ci_config_path": null,
2017-08-17 22:00:37 +05:30
"homepage":"http://example.com/gitlabhq/gitlab-test",
"url":"http://example.com/gitlabhq/gitlab-test.git",
"ssh_url":"git@example.com:gitlabhq/gitlab-test.git",
"http_url":"http://example.com/gitlabhq/gitlab-test.git"
},
"object_attributes": {
"id": 301,
"title": "New API: create/update/delete file",
"assignee_ids": [51],
"assignee_id": 51,
"author_id": 51,
"project_id": 14,
"created_at": "2013-12-03T17:15:43Z",
"updated_at": "2013-12-03T17:15:43Z",
2020-04-22 19:07:51 +05:30
"updated_by_id": 1,
"last_edited_at": null,
"last_edited_by_id": null,
"relative_position": 0,
2017-08-17 22:00:37 +05:30
"description": "Create new API for manipulations with repository",
"milestone_id": null,
2020-04-22 19:07:51 +05:30
"state_id": 1,
"confidential": false,
"discussion_locked": true,
"due_date": null,
"moved_to_id": null,
"duplicated_to_id": null,
"time_estimate": 0,
"total_time_spent": 0,
"human_total_time_spent": null,
"human_time_estimate": null,
"weight": null,
2017-08-17 22:00:37 +05:30
"iid": 23,
"url": "http://example.com/diaspora/issues/23",
2020-04-22 19:07:51 +05:30
"state": "opened",
"action": "open",
"labels": [{
"id": 206,
"title": "API",
"color": "#ffffff",
"project_id": 14,
"created_at": "2013-12-03T17:15:43Z",
"updated_at": "2013-12-03T17:15:43Z",
"template": false,
"description": "API related issues",
"type": "ProjectLabel",
"group_id": 41
}]
},
"repository": {
"name": "Gitlab Test",
"url": "http://example.com/gitlabhq/gitlab-test.git",
"description": "Aut reprehenderit ut est.",
"homepage": "http://example.com/gitlabhq/gitlab-test"
2017-08-17 22:00:37 +05:30
},
"assignees": [{
"name": "User1",
"username": "user1",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
}],
"assignee": {
"name": "User1",
"username": "user1",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
},
"labels": [{
"id": 206,
"title": "API",
"color": "#ffffff",
"project_id": 14,
"created_at": "2013-12-03T17:15:43Z",
"updated_at": "2013-12-03T17:15:43Z",
"template": false,
"description": "API related issues",
"type": "ProjectLabel",
"group_id": 41
2018-03-17 18:26:18 +05:30
}],
"changes": {
2019-09-04 21:01:54 +05:30
"updated_by_id": {
"previous": null,
"current": 1
},
"updated_at": {
2019-09-30 21:07:59 +05:30
"previous": "2017-09-15 16:50:55 UTC",
2019-09-04 21:01:54 +05:30
"current": "2017-09-15 16:52:00 UTC"
},
2018-03-17 18:26:18 +05:30
"labels": {
"previous": [{
"id": 206,
"title": "API",
"color": "#ffffff",
"project_id": 14,
"created_at": "2013-12-03T17:15:43Z",
"updated_at": "2013-12-03T17:15:43Z",
"template": false,
"description": "API related issues",
"type": "ProjectLabel",
"group_id": 41
}],
"current": [{
"id": 205,
"title": "Platform",
"color": "#123123",
"project_id": 14,
"created_at": "2013-12-03T17:15:43Z",
"updated_at": "2013-12-03T17:15:43Z",
"template": false,
"description": "Platform related issues",
"type": "ProjectLabel",
"group_id": 41
}]
}
}
2017-08-17 22:00:37 +05:30
}
```
2018-11-20 20:47:30 +05:30
> **Note**: `assignee` and `assignee_id` keys are deprecated and now show the first assignee only.
2017-08-17 22:00:37 +05:30
### Comment events
Triggered when a new comment is made on commits, merge requests, issues, and code snippets.
The note data will be stored in `object_attributes` (e.g. `note` , `noteable_type` ). The
payload will also include information about the target of the comment. For example,
2018-03-17 18:26:18 +05:30
a comment on an issue will include the specific issue information under the `issue` key.
2017-08-17 22:00:37 +05:30
Valid target types:
2019-02-15 15:39:39 +05:30
- `commit`
- `merge_request`
- `issue`
- `snippet`
2017-08-17 22:00:37 +05:30
#### Comment on commit
**Request header**:
2020-03-13 15:44:24 +05:30
```plaintext
2017-08-17 22:00:37 +05:30
X-Gitlab-Event: Note Hook
```
**Request body:**
```json
{
"object_kind": "note",
"user": {
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
},
"project_id": 5,
"project":{
2018-03-17 18:26:18 +05:30
"id": 5,
2017-08-17 22:00:37 +05:30
"name":"Gitlab Test",
"description":"Aut reprehenderit ut est.",
"web_url":"http://example.com/gitlabhq/gitlab-test",
"avatar_url":null,
"git_ssh_url":"git@example.com:gitlabhq/gitlab-test.git",
"git_http_url":"http://example.com/gitlabhq/gitlab-test.git",
"namespace":"GitlabHQ",
"visibility_level":20,
"path_with_namespace":"gitlabhq/gitlab-test",
"default_branch":"master",
"homepage":"http://example.com/gitlabhq/gitlab-test",
"url":"http://example.com/gitlabhq/gitlab-test.git",
"ssh_url":"git@example.com:gitlabhq/gitlab-test.git",
"http_url":"http://example.com/gitlabhq/gitlab-test.git"
},
"repository":{
"name": "Gitlab Test",
"url": "http://example.com/gitlab-org/gitlab-test.git",
"description": "Aut reprehenderit ut est.",
"homepage": "http://example.com/gitlab-org/gitlab-test"
},
"object_attributes": {
"id": 1243,
"note": "This is a commit comment. How does this work?",
"noteable_type": "Commit",
"author_id": 1,
"created_at": "2015-05-17 18:08:09 UTC",
"updated_at": "2015-05-17 18:08:09 UTC",
"project_id": 5,
"attachment":null,
"line_code": "bec9703f7a456cd2b4ab5fb3220ae016e3e394e3_0_1",
"commit_id": "cfe32cf61b73a0d5e9f13e774abde7ff789b1660",
"noteable_id": null,
"system": false,
"st_diff": {
"diff": "--- /dev/null\n+++ b/six\n@@ -0,0 +1 @@\n+Subproject commit 409f37c4f05865e4fb208c771485f211a22c4c2d\n",
"new_path": "six",
"old_path": "six",
"a_mode": "0",
"b_mode": "160000",
"new_file": true,
"renamed_file": false,
"deleted_file": false
},
"url": "http://example.com/gitlab-org/gitlab-test/commit/cfe32cf61b73a0d5e9f13e774abde7ff789b1660#note_1243"
},
"commit": {
"id": "cfe32cf61b73a0d5e9f13e774abde7ff789b1660",
2020-04-08 14:13:33 +05:30
"message": "Add submodule\n\nSigned-off-by: Example User \u003cuser@example.com.com\u003e\n",
2017-08-17 22:00:37 +05:30
"timestamp": "2014-02-27T10:06:20+02:00",
"url": "http://example.com/gitlab-org/gitlab-test/commit/cfe32cf61b73a0d5e9f13e774abde7ff789b1660",
"author": {
2020-04-08 14:13:33 +05:30
"name": "Example User",
"email": "user@example.com"
2017-08-17 22:00:37 +05:30
}
}
}
```
#### Comment on merge request
**Request header**:
2020-03-13 15:44:24 +05:30
```plaintext
2017-08-17 22:00:37 +05:30
X-Gitlab-Event: Note Hook
```
**Request body:**
```json
{
"object_kind": "note",
"user": {
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
},
"project_id": 5,
"project":{
2018-03-17 18:26:18 +05:30
"id": 5,
2017-08-17 22:00:37 +05:30
"name":"Gitlab Test",
"description":"Aut reprehenderit ut est.",
"web_url":"http://example.com/gitlab-org/gitlab-test",
"avatar_url":null,
"git_ssh_url":"git@example.com:gitlab-org/gitlab-test.git",
"git_http_url":"http://example.com/gitlab-org/gitlab-test.git",
"namespace":"Gitlab Org",
"visibility_level":10,
"path_with_namespace":"gitlab-org/gitlab-test",
"default_branch":"master",
"homepage":"http://example.com/gitlab-org/gitlab-test",
"url":"http://example.com/gitlab-org/gitlab-test.git",
"ssh_url":"git@example.com:gitlab-org/gitlab-test.git",
"http_url":"http://example.com/gitlab-org/gitlab-test.git"
},
"repository":{
"name": "Gitlab Test",
"url": "http://localhost/gitlab-org/gitlab-test.git",
"description": "Aut reprehenderit ut est.",
"homepage": "http://example.com/gitlab-org/gitlab-test"
},
"object_attributes": {
"id": 1244,
"note": "This MR needs work.",
"noteable_type": "MergeRequest",
"author_id": 1,
"created_at": "2015-05-17 18:21:36 UTC",
"updated_at": "2015-05-17 18:21:36 UTC",
"project_id": 5,
"attachment": null,
"line_code": null,
"commit_id": "",
"noteable_id": 7,
"system": false,
"st_diff": null,
"url": "http://example.com/gitlab-org/gitlab-test/merge_requests/1#note_1244"
},
"merge_request": {
"id": 7,
"target_branch": "markdown",
"source_branch": "master",
"source_project_id": 5,
"author_id": 8,
"assignee_id": 28,
"title": "Tempora et eos debitis quae laborum et.",
"created_at": "2015-03-01 20:12:53 UTC",
"updated_at": "2015-03-21 18:27:27 UTC",
"milestone_id": 11,
"state": "opened",
"merge_status": "cannot_be_merged",
"target_project_id": 5,
"iid": 1,
"description": "Et voluptas corrupti assumenda temporibus. Architecto cum animi eveniet amet asperiores. Vitae numquam voluptate est natus sit et ad id.",
"position": 0,
"source":{
"name":"Gitlab Test",
"description":"Aut reprehenderit ut est.",
"web_url":"http://example.com/gitlab-org/gitlab-test",
"avatar_url":null,
"git_ssh_url":"git@example.com:gitlab-org/gitlab-test.git",
"git_http_url":"http://example.com/gitlab-org/gitlab-test.git",
"namespace":"Gitlab Org",
"visibility_level":10,
"path_with_namespace":"gitlab-org/gitlab-test",
"default_branch":"master",
"homepage":"http://example.com/gitlab-org/gitlab-test",
"url":"http://example.com/gitlab-org/gitlab-test.git",
"ssh_url":"git@example.com:gitlab-org/gitlab-test.git",
"http_url":"http://example.com/gitlab-org/gitlab-test.git"
},
"target": {
"name":"Gitlab Test",
"description":"Aut reprehenderit ut est.",
"web_url":"http://example.com/gitlab-org/gitlab-test",
"avatar_url":null,
"git_ssh_url":"git@example.com:gitlab-org/gitlab-test.git",
"git_http_url":"http://example.com/gitlab-org/gitlab-test.git",
"namespace":"Gitlab Org",
"visibility_level":10,
"path_with_namespace":"gitlab-org/gitlab-test",
"default_branch":"master",
"homepage":"http://example.com/gitlab-org/gitlab-test",
"url":"http://example.com/gitlab-org/gitlab-test.git",
"ssh_url":"git@example.com:gitlab-org/gitlab-test.git",
"http_url":"http://example.com/gitlab-org/gitlab-test.git"
},
"last_commit": {
"id": "562e173be03b8ff2efb05345d12df18815438a4b",
"message": "Merge branch 'another-branch' into 'master'\n\nCheck in this test\n",
"timestamp": "2015-04-08T21: 00:25-07:00",
"url": "http://example.com/gitlab-org/gitlab-test/commit/562e173be03b8ff2efb05345d12df18815438a4b",
"author": {
"name": "John Smith",
"email": "john@example.com"
}
},
"work_in_progress": false,
"assignee": {
"name": "User1",
"username": "user1",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
}
}
}
```
#### Comment on issue
**Request header**:
2020-03-13 15:44:24 +05:30
```plaintext
2017-08-17 22:00:37 +05:30
X-Gitlab-Event: Note Hook
```
**Request body:**
```json
{
"object_kind": "note",
"user": {
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
},
"project_id": 5,
"project":{
2018-03-17 18:26:18 +05:30
"id": 5,
2017-08-17 22:00:37 +05:30
"name":"Gitlab Test",
"description":"Aut reprehenderit ut est.",
"web_url":"http://example.com/gitlab-org/gitlab-test",
"avatar_url":null,
"git_ssh_url":"git@example.com:gitlab-org/gitlab-test.git",
"git_http_url":"http://example.com/gitlab-org/gitlab-test.git",
"namespace":"Gitlab Org",
"visibility_level":10,
"path_with_namespace":"gitlab-org/gitlab-test",
"default_branch":"master",
"homepage":"http://example.com/gitlab-org/gitlab-test",
"url":"http://example.com/gitlab-org/gitlab-test.git",
"ssh_url":"git@example.com:gitlab-org/gitlab-test.git",
"http_url":"http://example.com/gitlab-org/gitlab-test.git"
},
"repository":{
"name":"diaspora",
"url":"git@example.com:mike/diaspora.git",
"description":"",
"homepage":"http://example.com/mike/diaspora"
},
"object_attributes": {
"id": 1241,
"note": "Hello world",
"noteable_type": "Issue",
"author_id": 1,
"created_at": "2015-05-17 17:06:40 UTC",
"updated_at": "2015-05-17 17:06:40 UTC",
"project_id": 5,
"attachment": null,
"line_code": null,
"commit_id": "",
"noteable_id": 92,
"system": false,
"st_diff": null,
"url": "http://example.com/gitlab-org/gitlab-test/issues/17#note_1241"
},
"issue": {
"id": 92,
"title": "test",
"assignee_ids": [],
"assignee_id": null,
"author_id": 1,
"project_id": 5,
"created_at": "2015-04-12 14:53:17 UTC",
"updated_at": "2015-04-26 08:28:42 UTC",
"position": 0,
"branch_name": null,
"description": "test",
"milestone_id": null,
"state": "closed",
2019-09-04 21:01:54 +05:30
"iid": 17,
"labels": [
{
"id": 25,
"title": "Afterpod",
"color": "#3e8068",
"project_id": null,
"created_at": "2019-06-05T14:32:20.211Z",
"updated_at": "2019-06-05T14:32:20.211Z",
"template": false,
"description": null,
"type": "GroupLabel",
"group_id": 4
},
{
"id": 86,
"title": "Element",
"color": "#231afe",
"project_id": 4,
"created_at": "2019-06-05T14:32:20.637Z",
"updated_at": "2019-06-05T14:32:20.637Z",
"template": false,
"description": null,
"type": "ProjectLabel",
"group_id": null
}
2020-10-24 23:57:45 +05:30
]
2017-08-17 22:00:37 +05:30
}
}
```
2018-11-20 20:47:30 +05:30
> **Note**: `assignee_id` field is deprecated and now shows the first assignee only.
2017-08-17 22:00:37 +05:30
#### Comment on code snippet
**Request header**:
2020-03-13 15:44:24 +05:30
```plaintext
2017-08-17 22:00:37 +05:30
X-Gitlab-Event: Note Hook
```
**Request body:**
```json
{
"object_kind": "note",
"user": {
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
},
"project_id": 5,
"project":{
2018-03-17 18:26:18 +05:30
"id": 5,
2017-08-17 22:00:37 +05:30
"name":"Gitlab Test",
"description":"Aut reprehenderit ut est.",
"web_url":"http://example.com/gitlab-org/gitlab-test",
"avatar_url":null,
"git_ssh_url":"git@example.com:gitlab-org/gitlab-test.git",
"git_http_url":"http://example.com/gitlab-org/gitlab-test.git",
"namespace":"Gitlab Org",
"visibility_level":10,
"path_with_namespace":"gitlab-org/gitlab-test",
"default_branch":"master",
"homepage":"http://example.com/gitlab-org/gitlab-test",
"url":"http://example.com/gitlab-org/gitlab-test.git",
"ssh_url":"git@example.com:gitlab-org/gitlab-test.git",
"http_url":"http://example.com/gitlab-org/gitlab-test.git"
},
"repository":{
"name":"Gitlab Test",
"url":"http://example.com/gitlab-org/gitlab-test.git",
"description":"Aut reprehenderit ut est.",
"homepage":"http://example.com/gitlab-org/gitlab-test"
},
"object_attributes": {
"id": 1245,
"note": "Is this snippet doing what it's supposed to be doing?",
"noteable_type": "Snippet",
"author_id": 1,
"created_at": "2015-05-17 18:35:50 UTC",
"updated_at": "2015-05-17 18:35:50 UTC",
"project_id": 5,
"attachment": null,
"line_code": null,
"commit_id": "",
"noteable_id": 53,
"system": false,
"st_diff": null,
"url": "http://example.com/gitlab-org/gitlab-test/snippets/53#note_1245"
},
"snippet": {
"id": 53,
"title": "test",
"content": "puts 'Hello world'",
"author_id": 1,
"project_id": 5,
"created_at": "2015-04-09 02:40:38 UTC",
"updated_at": "2015-04-09 02:40:38 UTC",
"file_name": "test.rb",
"expires_at": null,
"type": "ProjectSnippet",
"visibility_level": 0
}
}
```
### Merge request events
Triggered when a new merge request is created, an existing merge request was updated/merged/closed or a commit is added in the source branch.
**Request header**:
2020-03-13 15:44:24 +05:30
```plaintext
2017-08-17 22:00:37 +05:30
X-Gitlab-Event: Merge Request Hook
```
**Request body:**
```json
{
"object_kind": "merge_request",
"user": {
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
},
2018-03-17 18:26:18 +05:30
"project": {
"id": 1,
"name":"Gitlab Test",
"description":"Aut reprehenderit ut est.",
"web_url":"http://example.com/gitlabhq/gitlab-test",
"avatar_url":null,
"git_ssh_url":"git@example.com:gitlabhq/gitlab-test.git",
"git_http_url":"http://example.com/gitlabhq/gitlab-test.git",
"namespace":"GitlabHQ",
"visibility_level":20,
"path_with_namespace":"gitlabhq/gitlab-test",
"default_branch":"master",
"homepage":"http://example.com/gitlabhq/gitlab-test",
"url":"http://example.com/gitlabhq/gitlab-test.git",
"ssh_url":"git@example.com:gitlabhq/gitlab-test.git",
"http_url":"http://example.com/gitlabhq/gitlab-test.git"
},
"repository": {
"name": "Gitlab Test",
"url": "http://example.com/gitlabhq/gitlab-test.git",
"description": "Aut reprehenderit ut est.",
"homepage": "http://example.com/gitlabhq/gitlab-test"
},
2017-08-17 22:00:37 +05:30
"object_attributes": {
"id": 99,
"target_branch": "master",
"source_branch": "ms-viewport",
"source_project_id": 14,
"author_id": 51,
"assignee_id": 6,
"title": "MS-Viewport",
"created_at": "2013-12-03T17:23:34Z",
"updated_at": "2013-12-03T17:23:34Z",
"milestone_id": null,
"state": "opened",
"merge_status": "unchecked",
"target_project_id": 14,
"iid": 1,
"description": "",
2018-03-17 18:26:18 +05:30
"source": {
2017-08-17 22:00:37 +05:30
"name":"Awesome Project",
"description":"Aut reprehenderit ut est.",
"web_url":"http://example.com/awesome_space/awesome_project",
"avatar_url":null,
"git_ssh_url":"git@example.com:awesome_space/awesome_project.git",
"git_http_url":"http://example.com/awesome_space/awesome_project.git",
"namespace":"Awesome Space",
"visibility_level":20,
"path_with_namespace":"awesome_space/awesome_project",
"default_branch":"master",
"homepage":"http://example.com/awesome_space/awesome_project",
"url":"http://example.com/awesome_space/awesome_project.git",
"ssh_url":"git@example.com:awesome_space/awesome_project.git",
"http_url":"http://example.com/awesome_space/awesome_project.git"
},
"target": {
"name":"Awesome Project",
"description":"Aut reprehenderit ut est.",
"web_url":"http://example.com/awesome_space/awesome_project",
"avatar_url":null,
"git_ssh_url":"git@example.com:awesome_space/awesome_project.git",
"git_http_url":"http://example.com/awesome_space/awesome_project.git",
"namespace":"Awesome Space",
"visibility_level":20,
"path_with_namespace":"awesome_space/awesome_project",
"default_branch":"master",
"homepage":"http://example.com/awesome_space/awesome_project",
"url":"http://example.com/awesome_space/awesome_project.git",
"ssh_url":"git@example.com:awesome_space/awesome_project.git",
"http_url":"http://example.com/awesome_space/awesome_project.git"
},
"last_commit": {
"id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"message": "fixed readme",
"timestamp": "2012-01-03T23:36:29+02:00",
"url": "http://example.com/awesome_space/awesome_project/commits/da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"author": {
"name": "GitLab dev user",
"email": "gitlabdev@dv6700.(none)"
}
},
"work_in_progress": false,
"url": "http://example.com/diaspora/merge_requests/1",
"action": "open",
"assignee": {
"name": "User1",
"username": "user1",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
}
2018-03-17 18:26:18 +05:30
},
"labels": [{
"id": 206,
"title": "API",
"color": "#ffffff",
"project_id": 14,
"created_at": "2013-12-03T17:15:43Z",
"updated_at": "2013-12-03T17:15:43Z",
"template": false,
"description": "API related issues",
"type": "ProjectLabel",
"group_id": 41
}],
"changes": {
2019-09-04 21:01:54 +05:30
"updated_by_id": {
"previous": null,
"current": 1
},
"updated_at": {
2019-09-30 21:07:59 +05:30
"previous": "2017-09-15 16:50:55 UTC",
2019-09-04 21:01:54 +05:30
"current":"2017-09-15 16:52:00 UTC"
},
2018-03-17 18:26:18 +05:30
"labels": {
"previous": [{
"id": 206,
"title": "API",
"color": "#ffffff",
"project_id": 14,
"created_at": "2013-12-03T17:15:43Z",
"updated_at": "2013-12-03T17:15:43Z",
"template": false,
"description": "API related issues",
"type": "ProjectLabel",
"group_id": 41
}],
"current": [{
"id": 205,
"title": "Platform",
"color": "#123123",
"project_id": 14,
"created_at": "2013-12-03T17:15:43Z",
"updated_at": "2013-12-03T17:15:43Z",
"template": false,
"description": "Platform related issues",
"type": "ProjectLabel",
"group_id": 41
}]
}
2017-08-17 22:00:37 +05:30
}
}
```
### Wiki Page events
2017-09-10 17:25:29 +05:30
Triggered when a wiki page is created, updated or deleted.
2017-08-17 22:00:37 +05:30
**Request Header**:
2020-03-13 15:44:24 +05:30
```plaintext
2017-08-17 22:00:37 +05:30
X-Gitlab-Event: Wiki Page Hook
```
**Request Body**:
```json
{
"object_kind": "wiki_page",
"user": {
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon"
},
"project": {
2018-03-17 18:26:18 +05:30
"id": 1,
2017-08-17 22:00:37 +05:30
"name": "awesome-project",
"description": "This is awesome",
"web_url": "http://example.com/root/awesome-project",
"avatar_url": null,
"git_ssh_url": "git@example.com:root/awesome-project.git",
"git_http_url": "http://example.com/root/awesome-project.git",
"namespace": "root",
"visibility_level": 0,
"path_with_namespace": "root/awesome-project",
"default_branch": "master",
"homepage": "http://example.com/root/awesome-project",
"url": "git@example.com:root/awesome-project.git",
"ssh_url": "git@example.com:root/awesome-project.git",
"http_url": "http://example.com/root/awesome-project.git"
},
"wiki": {
2020-01-01 13:55:28 +05:30
"web_url": "http://example.com/root/awesome-project/-/wikis/home",
2017-08-17 22:00:37 +05:30
"git_ssh_url": "git@example.com:root/awesome-project.wiki.git",
"git_http_url": "http://example.com/root/awesome-project.wiki.git",
"path_with_namespace": "root/awesome-project.wiki",
"default_branch": "master"
},
"object_attributes": {
"title": "Awesome",
"content": "awesome content goes here",
"format": "markdown",
"message": "adding an awesome page to the wiki",
"slug": "awesome",
2020-01-01 13:55:28 +05:30
"url": "http://example.com/root/awesome-project/-/wikis/awesome",
2017-08-17 22:00:37 +05:30
"action": "create"
}
}
```
### Pipeline events
Triggered on status change of Pipeline.
**Request Header**:
2020-03-13 15:44:24 +05:30
```plaintext
2017-08-17 22:00:37 +05:30
X-Gitlab-Event: Pipeline Hook
```
**Request Body**:
```json
{
"object_kind": "pipeline",
"object_attributes":{
"id": 31,
"ref": "master",
"tag": false,
"sha": "bcbb5ec396a2c0f828686f14fac9b80b780504f2",
"before_sha": "bcbb5ec396a2c0f828686f14fac9b80b780504f2",
2019-12-04 20:38:33 +05:30
"source": "merge_request_event",
2017-08-17 22:00:37 +05:30
"status": "success",
"stages":[
"build",
"test",
"deploy"
],
"created_at": "2016-08-12 15:23:28 UTC",
"finished_at": "2016-08-12 15:26:29 UTC",
2018-12-05 23:21:45 +05:30
"duration": 63,
"variables": [
{
"key": "NESTOR_PROD_ENVIRONMENT",
"value": "us-west-1"
}
]
2019-12-04 20:38:33 +05:30
},
"merge_request": {
"id": 1,
"iid": 1,
"title": "Test",
"source_branch": "test",
"source_project_id": 1,
"target_branch": "master",
"target_project_id": 1,
"state": "opened",
"merge_status": "can_be_merged",
"url": "http://192.168.64.1:3005/gitlab-org/gitlab-test/merge_requests/1"
2017-08-17 22:00:37 +05:30
},
"user":{
"name": "Administrator",
"username": "root",
2020-03-13 15:44:24 +05:30
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon",
"email": "user_email@gitlab.com"
2017-08-17 22:00:37 +05:30
},
"project":{
2018-03-17 18:26:18 +05:30
"id": 1,
2017-08-17 22:00:37 +05:30
"name": "Gitlab Test",
"description": "Atque in sunt eos similique dolores voluptatem.",
"web_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test",
"avatar_url": null,
"git_ssh_url": "git@192.168.64.1:gitlab-org/gitlab-test.git",
"git_http_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test.git",
"namespace": "Gitlab Org",
"visibility_level": 20,
"path_with_namespace": "gitlab-org/gitlab-test",
"default_branch": "master"
},
"commit":{
"id": "bcbb5ec396a2c0f828686f14fac9b80b780504f2",
"message": "test\n",
"timestamp": "2016-08-12T17:23:21+02:00",
"url": "http://example.com/gitlab-org/gitlab-test/commit/bcbb5ec396a2c0f828686f14fac9b80b780504f2",
"author":{
"name": "User",
"email": "user@gitlab.com"
}
},
2019-09-04 21:01:54 +05:30
"builds":[
2017-08-17 22:00:37 +05:30
{
"id": 380,
"stage": "deploy",
"name": "production",
"status": "skipped",
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": null,
"finished_at": null,
"when": "manual",
"manual": true,
2020-01-01 13:55:28 +05:30
"allow_failure": false,
2017-08-17 22:00:37 +05:30
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
"runner": null,
"artifacts_file":{
"filename": null,
"size": null
}
},
{
"id": 377,
"stage": "test",
"name": "test-image",
"status": "success",
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": "2016-08-12 15:26:12 UTC",
"finished_at": null,
"when": "on_success",
"manual": false,
2020-01-01 13:55:28 +05:30
"allow_failure": false,
2017-08-17 22:00:37 +05:30
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
2019-07-07 11:18:12 +05:30
"runner": {
"id":380987,
"description":"shared-runners-manager-6.gitlab.com",
"active":true,
"is_shared":true
},
2017-08-17 22:00:37 +05:30
"artifacts_file":{
"filename": null,
"size": null
}
},
{
"id": 378,
"stage": "test",
"name": "test-build",
"status": "success",
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": "2016-08-12 15:26:12 UTC",
"finished_at": "2016-08-12 15:26:29 UTC",
"when": "on_success",
"manual": false,
2020-01-01 13:55:28 +05:30
"allow_failure": false,
2017-08-17 22:00:37 +05:30
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
2019-07-07 11:18:12 +05:30
"runner": {
"id":380987,
"description":"shared-runners-manager-6.gitlab.com",
"active":true,
"is_shared":true
},
2017-08-17 22:00:37 +05:30
"artifacts_file":{
"filename": null,
"size": null
}
},
{
"id": 376,
"stage": "build",
"name": "build-image",
"status": "success",
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": "2016-08-12 15:24:56 UTC",
"finished_at": "2016-08-12 15:25:26 UTC",
"when": "on_success",
"manual": false,
2020-01-01 13:55:28 +05:30
"allow_failure": false,
2017-08-17 22:00:37 +05:30
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
2019-07-07 11:18:12 +05:30
"runner": {
"id":380987,
"description":"shared-runners-manager-6.gitlab.com",
"active":true,
"is_shared":true
},
2017-08-17 22:00:37 +05:30
"artifacts_file":{
"filename": null,
"size": null
}
},
{
"id": 379,
"stage": "deploy",
"name": "staging",
"status": "created",
"created_at": "2016-08-12 15:23:28 UTC",
"started_at": null,
"finished_at": null,
"when": "on_success",
"manual": false,
2020-01-01 13:55:28 +05:30
"allow_failure": false,
2017-08-17 22:00:37 +05:30
"user":{
"name": "Administrator",
"username": "root",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
},
"runner": null,
"artifacts_file":{
"filename": null,
"size": null
}
}
]
}
```
2019-07-07 11:18:12 +05:30
### Job events
2017-08-17 22:00:37 +05:30
2019-07-07 11:18:12 +05:30
Triggered on status change of a job.
2017-08-17 22:00:37 +05:30
**Request Header**:
2020-03-13 15:44:24 +05:30
```plaintext
2019-07-07 11:18:12 +05:30
X-Gitlab-Event: Job Hook
2017-08-17 22:00:37 +05:30
```
**Request Body**:
```json
{
2019-12-04 20:38:33 +05:30
"object_kind": "build",
2017-08-17 22:00:37 +05:30
"ref": "gitlab-script-trigger",
"tag": false,
"before_sha": "2293ada6b400935a1378653304eaf6221e0fdb8f",
"sha": "2293ada6b400935a1378653304eaf6221e0fdb8f",
2019-12-04 20:38:33 +05:30
"build_id": 1977,
"build_name": "test",
"build_stage": "test",
"build_status": "created",
"build_started_at": null,
"build_finished_at": null,
"build_duration": null,
"build_allow_failure": false,
"build_failure_reason": "script_failure",
2020-01-01 13:55:28 +05:30
"pipeline_id": 2366,
2017-08-17 22:00:37 +05:30
"project_id": 380,
"project_name": "gitlab-org/gitlab-test",
"user": {
"id": 3,
"name": "User",
2020-03-13 15:44:24 +05:30
"email": "user@gitlab.com",
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
2017-08-17 22:00:37 +05:30
},
"commit": {
"id": 2366,
"sha": "2293ada6b400935a1378653304eaf6221e0fdb8f",
"message": "test\n",
"author_name": "User",
"author_email": "user@gitlab.com",
"status": "created",
"duration": null,
"started_at": null,
"finished_at": null
},
"repository": {
"name": "gitlab_test",
"description": "Atque in sunt eos similique dolores voluptatem.",
"homepage": "http://192.168.64.1:3005/gitlab-org/gitlab-test",
"git_ssh_url": "git@192.168.64.1:gitlab-org/gitlab-test.git",
"git_http_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test.git",
"visibility_level": 20
2020-01-01 13:55:28 +05:30
},
"runner": {
"active": true,
"is_shared": false,
"id": 380987,
"description": "shared-runners-manager-6.gitlab.com"
2017-08-17 22:00:37 +05:30
}
}
```
2020-05-24 23:13:21 +05:30
Note that `commit.id` is the ID of the pipeline, not the ID of the commit.
2020-01-01 13:55:28 +05:30
2020-10-24 23:57:45 +05:30
### Deployment events
Triggered when deployment is finished/failed/canceled.
**Request Header**:
```plaintext
X-Gitlab-Event: Deployment Hook
```
**Request Body**:
```json
{
"object_kind": "deployment",
"status": "success",
"deployable_id": 796,
"deployable_url": "http://10.126.0.2:3000/root/test-deployment-webhooks/-/jobs/796",
"environment": "staging",
"project": {
"id": 30,
"name": "test-deployment-webhooks",
"description": "",
"web_url": "http://10.126.0.2:3000/root/test-deployment-webhooks",
"avatar_url": null,
"git_ssh_url": "ssh://vlad@10.126.0.2:2222/root/test-deployment-webhooks.git",
"git_http_url": "http://10.126.0.2:3000/root/test-deployment-webhooks.git",
"namespace": "Administrator",
"visibility_level": 0,
"path_with_namespace": "root/test-deployment-webhooks",
"default_branch": "master",
"ci_config_path": "",
"homepage": "http://10.126.0.2:3000/root/test-deployment-webhooks",
"url": "ssh://vlad@10.126.0.2:2222/root/test-deployment-webhooks.git",
"ssh_url": "ssh://vlad@10.126.0.2:2222/root/test-deployment-webhooks.git",
"http_url": "http://10.126.0.2:3000/root/test-deployment-webhooks.git"
},
"short_sha": "279484c0",
"user": {
"name": "Administrator",
"username": "root",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80& d=identicon",
"email": "admin@example.com"
},
"user_url": "http://10.126.0.2:3000/root",
"commit_url": "http://10.126.0.2:3000/root/test-deployment-webhooks/-/commit/279484c09fbe69ededfced8c1bb6e6d24616b468",
"commit_title": "Add new file"
}
```
Note that `deployable_id` is the ID of the CI job.
2018-11-18 11:00:15 +05:30
## Image URL rewriting
From GitLab 11.2, simple image references are rewritten to use an absolute URL
in webhooks. So if an image, merge request, comment, or wiki page has this in
its description:
```markdown
![image ](/uploads/$sha/image.png )
```
It will appear in the webhook body as the below (assuming that GitLab is
2019-12-21 20:55:43 +05:30
installed at `gitlab.example.com` , and the project is at
`example-group/example-project` ):
2018-11-18 11:00:15 +05:30
```markdown
2018-12-13 13:39:08 +05:30
![image ](https://gitlab.example.com/example-group/example-project/uploads/$sha/image.png )
2018-11-18 11:00:15 +05:30
```
This will not rewrite URLs that already are pointing to HTTP, HTTPS, or
protocol-relative URLs. It will also not rewrite image URLs using advanced
Markdown features, like link labels.
2017-09-10 17:25:29 +05:30
## Testing webhooks
2020-04-08 14:13:33 +05:30
You can trigger the webhook manually. Sample data from the project will be used.
2017-09-10 17:25:29 +05:30
> For example: for triggering `Push Events` your project should have at least one commit.
![Webhook testing ](img/webhook_testing.png )
## Troubleshoot webhooks
2018-12-05 23:21:45 +05:30
GitLab stores each perform of the webhook.
2017-09-10 17:25:29 +05:30
You can find records for last 2 days in "Recent Deliveries" section on the edit page of each webhook.
![Recent deliveries ](img/webhook_logs.png )
In this section you can see HTTP status code (green for 200-299 codes, red for the others, `internal error` for failed deliveries ), triggered event, a time when the event was called, elapsed time of the request.
If you need more information about execution, you can click `View details` link.
On this page, you can see data that GitLab sends (request headers and body) and data that it received (response headers and body).
From this page, you can repeat delivery with the same data by clicking `Resend Request` button.
2020-10-24 23:57:45 +05:30
NOTE: **Note:**
If URL or secret token of the webhook were updated, data will be delivered to the new address.
2017-09-10 17:25:29 +05:30
2018-12-13 13:39:08 +05:30
### Receiving duplicate or multiple webhook requests triggered by one event
2018-03-17 18:26:18 +05:30
When GitLab sends a webhook it expects a response in 10 seconds (set default value). If it does not receive one, it'll retry the webhook.
If the endpoint doesn't send its HTTP response within those 10 seconds, GitLab may decide the hook failed and retry it.
2018-11-08 19:23:39 +05:30
If you are receiving multiple requests, you can try increasing the default value to wait for the HTTP response after sending the webhook
2018-03-17 18:26:18 +05:30
by uncommenting or adding the following setting to your `/etc/gitlab/gitlab.rb` :
2020-03-13 15:44:24 +05:30
```ruby
2018-11-08 19:23:39 +05:30
gitlab_rails['webhook_timeout'] = 10
2018-03-17 18:26:18 +05:30
```
2019-07-07 11:18:12 +05:30
### Troubleshooting: "Unable to get local issuer certificate"
When SSL verification is enabled, this error indicates that GitLab isn't able to verify the SSL certificate of the webhook endpoint.
Typically, this is because the root certificate isn't issued by a trusted certification authority as
determined by [CAcert.org ](http://www.cacert.org/ ).
Should that not be the case, consider using [SSL Checker ](https://www.sslshopper.com/ssl-checker.html ) to identify faults.
Missing intermediate certificates are a common point of verification failure.
2017-08-17 22:00:37 +05:30
## Example webhook receiver
If you want to see GitLab's webhooks in action for testing purposes you can use
a simple echo script running in a console session. For the following script to
work you need to have Ruby installed.
Save the following file as `print_http_body.rb` :
```ruby
require 'webrick'
server = WEBrick::HTTPServer.new(:Port => ARGV.first)
server.mount_proc '/' do |req, res|
puts req.body
end
trap 'INT' do
server.shutdown
end
server.start
```
Pick an unused port (e.g. 8000) and start the script: `ruby print_http_body.rb
2020-03-13 15:44:24 +05:30
8000`. Then add your server as a webhook receiver in GitLab as
2017-08-17 22:00:37 +05:30
`http://my.host:8000/` .
2017-09-10 17:25:29 +05:30
When you press 'Test' in GitLab, you should see something like this in the
2017-08-17 22:00:37 +05:30
console:
2020-03-13 15:44:24 +05:30
```plaintext
2017-08-17 22:00:37 +05:30
{"before":"077a85dd266e6f3573ef7e9ef8ce3343ad659c4e","after":"95cd4a99e93bc4bbabacfa2cd10e6725b1403c60",< SNIP > }
example.com - - [14/May/2014:07:45:26 EDT] "POST / HTTP/1.1" 200 0
- -> /
```
2019-12-04 20:38:33 +05:30
NOTE: **Note:**
You may need to [allow requests to the local network ](../../../security/webhooks.md ) for this receiver to be added.