极狐 GitLab

Webhook 事件

Tier: 基础版,专业版,旗舰版

Offering: JihuLab.com,私有化部署

使用 webhook 将极狐GitLab 连接到你的外部应用程序,自动化你的工作流程。 当极狐GitLab 中发生特定事件时,webhook 会向你配置的端点发送包含详细信息的 HTTP POST 请求。 构建自动化流程,响应代码更改、部署、评论和其他活动,无需手动干预。

本页面列出了项目 webhook群组 webhook 触发的事件。

有关系统 webhook 触发的事件列表,请参阅系统 webhook

项目和群组 webhook 均触发的事件#

事件类型触发器
评论事件在提交、合并请求、议题和代码片段上创建或编辑新评论。 1
部署事件部署开始、成功、失败或被取消。
表情事件添加或移除表情反应。
功能标志事件开启或关闭功能标志。
作业事件作业状态发生变化。
合并请求事件合并请求被创建、编辑、合并或关闭,或在源分支中添加提交。
里程碑事件里程碑被创建、关闭、重新打开或删除。
流水线事件流水线状态发生变化。
项目或群组访问令牌事件项目或群组访问令牌将在 7、30 或 60 天后过期。
推送事件向仓库执行推送操作。
发布事件发布被创建、编辑或删除。
标签事件仓库中创建或删除标签。
漏洞事件漏洞被创建或更新。
Wiki 页面事件Wiki 页面被创建、编辑或删除。
工作项事件创建新工作项或编辑、关闭、重新打开现有工作项。

脚注:

  1. 评论事件在评论被编辑时触发,引入于极狐GitLab 16.11。

仅群组 webhook 触发的事件#

事件类型触发器
群组成员事件用户被添加到群组或从群组中移除,或者用户的访问级别或访问过期日期发生变化。
项目事件群组中创建或删除项目。
子群组事件从群组中创建或删除子群组。
如果作者在其 [极狐GitLab 个人资料](https://gitlab.com/-/user_settings/profile) 中没有列出公开电子邮件,则 webhook 负载中的 `email` 属性会显示 `[REDACTED]` 值。

推送事件#

当你向仓库推送时,会触发推送事件,以下情况除外:

如果你一次推送超过 20 个提交,负载中的 commits 属性仅包含最新 20 个提交的信息。 加载详细的提交数据开销很大,因此出于性能考虑,此限制存在。 total_commits_count 属性包含实际提交数量。

单独的设置 `push_event_activities_limit` 控制极狐GitLab 在活动源中是创建单独的推送事件还是批量推送事件。更多信息,请参阅 [推送事件活动限制](../../../administration/settings/push_event_activities_limit.md)。

如果你创建并推送一个没有任何新提交的分支,负载中的 commits 属性为空。

请求头:

plaintext
X-Gitlab-Event: Push Hook

负载示例:

json
1{ 2 "object_kind": "push", 3 "event_name": "push", 4 "before": "95790bf891e76fee5e1747ab589903a6a1f80f22", 5 "after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", 6 "ref": "refs/heads/master", 7 "ref_protected": true, 8 "checkout_sha": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", 9 "message": "Hello World", 10 "user_id": 4, 11 "user_name": "John Smith", 12 "user_username": "jsmith", 13 "user_email": "john@example.com", 14 "user_avatar": "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80", 15 "project_id": 15, 16 "project": { 17 "id": 15, 18 "name": "Diaspora", 19 "description": "", 20 "web_url": "http://example.com/mike/diaspora", 21 "avatar_url": null, 22 "git_ssh_url": "git@example.com:mike/diaspora.git", 23 "git_http_url": "http://example.com/mike/diaspora.git", 24 "namespace": "Mike", 25 "visibility_level": 0, 26 "path_with_namespace": "mike/diaspora", 27 "default_branch": "master", 28 "ci_config_path": null, 29 "homepage": "http://example.com/mike/diaspora", 30 "url": "git@example.com:mike/diaspora.git", 31 "ssh_url": "git@example.com:mike/diaspora.git", 32 "http_url": "http://example.com/mike/diaspora.git" 33 }, 34 "commits": [ 35 { 36 "id": "b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327", 37 "message": "Update Catalan translation to e38cb41.\n\nSee https://gitlab.com/gitlab-org/gitlab for more information", 38 "title": "Update Catalan translation to e38cb41.", 39 "timestamp": "2011-12-12T14:27:31+02:00", 40 "url": "http://example.com/mike/diaspora/commit/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327", 41 "author": { 42 "name": "Jordi Mallach", 43 "email": "jordi@softcatala.org" 44 }, 45 "added": ["CHANGELOG"], 46 "modified": ["app/controller/application.rb"], 47 "removed": [] 48 }, 49 { 50 "id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", 51 "message": "fixed readme", 52 "title": "fixed readme", 53 "timestamp": "2012-01-03T23:36:29+02:00", 54 "url": "http://example.com/mike/diaspora/commit/da1560886d4f094c3e6c9ef40349f7d38b5d27d7", 55 "author": { 56 "name": "GitLab dev user", 57 "email": "gitlabdev@dv6700.(none)" 58 }, 59 "added": ["CHANGELOG"], 60 "modified": ["app/controller/application.rb"], 61 "removed": [] 62 } 63 ], 64 "total_commits_count": 4, 65 "push_options": {}, 66 "repository": { 67 "name": "Diaspora", 68 "url": "git@example.com:mike/diaspora.git", 69 "description": "", 70 "homepage": "http://example.com/mike/diaspora", 71 "git_http_url": "http://example.com/mike/diaspora.git", 72 "git_ssh_url": "git@example.com:mike/diaspora.git", 73 "visibility_level": 0 74 } 75}

标签事件#

当你在仓库中创建或删除标签时,会触发标签事件。

默认情况下,如果单次推送包含超过三个标签的变更,则不会执行此钩子。 此限制由 push_event_hooks_limit 设置(默认值:3)控制,该设置同时适用于标签和分支。当超出限制时,此次推送事件将完全不触发任何 webhook。

对于私有化部署的极狐GitLab 实例,管理员可以使用 应用程序设置 API 修改此限制。

请求头:

plaintext
X-Gitlab-Event: Tag Push Hook

负载示例:

json
1{ 2 "object_kind": "tag_push", 3 "event_name": "tag_push", 4 "before": "0000000000000000000000000000000000000000", 5 "after": "82b3d5ae55f7080f1e6022629cdb57bfae7cccc7", 6 "ref": "refs/tags/v1.0.0", 7 "ref_protected": true, 8 "checkout_sha": "82b3d5ae55f7080f1e6022629cdb57bfae7cccc7", 9 "message": "Tag message", 10 "user_id": 1, 11 "user_name": "John Smith", 12 "user_username": "jsmith", 13 "user_email": "john@example.com", 14 "user_avatar": "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80", 15 "project_id": 1, 16 "project": { 17 "id": 1, 18 "name": "Example", 19 "description": "", 20 "web_url": "http://example.com/jsmith/example", 21 "avatar_url": null, 22 "git_ssh_url": "git@example.com:jsmith/example.git", 23 "git_http_url": "http://example.com/jsmith/example.git", 24 "namespace": "Jsmith", 25 "visibility_level": 0, 26 "path_with_namespace": "jsmith/example", 27 "default_branch": "master", 28 "ci_config_path": null, 29 "homepage": "http://example.com/jsmith/example", 30 "url": "git@example.com:jsmith/example.git", 31 "ssh_url": "git@example.com:jsmith/example.git", 32 "http_url": "http://example.com/jsmith/example.git" 33 }, 34 "commits": [], 35 "total_commits_count": 0, 36 "push_options": {}, 37 "repository": { 38 "name": "Example", 39 "url": "ssh://git@example.com/jsmith/example.git", 40 "description": "", 41 "homepage": "http://example.com/jsmith/example", 42 "git_http_url": "http://example.com/jsmith/example.git", 43 "git_ssh_url": "git@example.com:jsmith/example.git", 44 "visibility_level": 0 45 } 46}

工作项事件#

版本历史
  • object_attributes 中的 type 属性于极狐GitLab 17.2 引入。
  • 对史诗的支持于极狐GitLab 17.3 引入。必须启用史诗的新外观
  • 对史诗的支持于极狐GitLab 18.1 GA。

工作项事件在工作项被创建、编辑、关闭或重新打开时触发。 支持的工作项类型包括:

对于议题和 Service Desk 议题,object_kindissuetypeIssue。 对于所有其他工作项,object_kind 字段为 work_itemtype 为工作项类型。

对于类型为 Epic 的工作项,要获取变更事件,必须为群组注册 webhook。

负载中 object_attributes.action 的可用值为:

  • open
  • close
  • reopen
  • update

assigneeassignee_id 键已被弃用,仅包含第一个指派人。

escalation_statusescalation_policy 字段仅适用于支持升级规则的问题类型,例如事件。

请求头:

plaintext
X-Gitlab-Event: Issue Hook

负载示例:

json
1{ 2 "object_kind": "issue", 3 "event_type": "issue", 4 "user": { 5 "id": 1, 6 "name": "Administrator", 7 "username": "root", 8 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon", 9 "email": "admin@example.com" 10 }, 11 "project": { 12 "id": 1, 13 "name":"Gitlab Test", 14 "description":"Aut reprehenderit ut est.", 15 "web_url":"http://example.com/gitlabhq/gitlab-test", 16 "avatar_url":null, 17 "git_ssh_url":"git@example.com:gitlabhq/gitlab-test.git", 18 "git_http_url":"http://example.com/gitlabhq/gitlab-test.git", 19 "namespace":"GitlabHQ", 20 "visibility_level":20, 21 "path_with_namespace":"gitlabhq/gitlab-test", 22 "default_branch":"master", 23 "ci_config_path": null, 24 "homepage":"http://example.com/gitlabhq/gitlab-test", 25 "url":"http://example.com/gitlabhq/gitlab-test.git", 26 "ssh_url":"git@example.com:gitlabhq/gitlab-test.git", 27 "http_url":"http://example.com/gitlabhq/gitlab-test.git" 28 }, 29 "object_attributes": { 30 "id": 301, 31 "title": "New API: create/update/delete file", 32 "assignee_ids": [51], 33 "assignee_id": 51, 34 "author_id": 51, 35 "project_id": 14, 36 "created_at": "2013-12-03T17:15:43Z", 37 "updated_at": "2013-12-03T17:15:43Z", 38 "updated_by_id": 1, 39 "last_edited_at": null, 40 "last_edited_by_id": null, 41 "relative_position": 0, 42 "description": "Create new API for manipulations with repository", 43 "milestone_id": null, 44 "state_id": 1, 45 "confidential": false, 46 "discussion_locked": true, 47 "due_date": null, 48 "moved_to_id": null, 49 "duplicated_to_id": null, 50 "time_estimate": 0, 51 "total_time_spent": 0, 52 "time_change": 0, 53 "human_total_time_spent": null, 54 "human_time_estimate": null, 55 "human_time_change": null, 56 "weight": null, 57 "health_status": "at_risk", 58 "type": "Issue", 59 "iid": 23, 60 "url": "http://example.com/diaspora/issues/23", 61 "state": "opened", 62 "action": "open", 63 "severity": "high", 64 "escalation_status": "triggered", 65 "escalation_policy": { 66 "id": 18, 67 "name": "Engineering On-call" 68 }, 69 "labels": [{ 70 "id": 206, 71 "title": "API", 72 "color": "#ffffff", 73 "project_id": 14, 74 "created_at": "2013-12-03T17:15:43Z", 75 "updated_at": "2013-12-03T17:15:43Z", 76 "template": false, 77 "description": "API related issues", 78 "type": "ProjectLabel", 79 "group_id": 41 80 }] 81 }, 82 "repository": { 83 "name": "Gitlab Test", 84 "url": "http://example.com/gitlabhq/gitlab-test.git", 85 "description": "Aut reprehenderit ut est.", 86 "homepage": "http://example.com/gitlabhq/gitlab-test" 87 }, 88 "assignees": [{ 89 "name": "User1", 90 "username": "user1", 91 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon" 92 }], 93 "assignee": { 94 "name": "User1", 95 "username": "user1", 96 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon" 97 }, 98 "labels": [{ 99 "id": 206, 100 "title": "API", 101 "color": "#ffffff", 102 "project_id": 14, 103 "created_at": "2013-12-03T17:15:43Z", 104 "updated_at": "2013-12-03T17:15:43Z", 105 "template": false, 106 "description": "API related issues", 107 "type": "ProjectLabel", 108 "group_id": 41 109 }], 110 "changes": { 111 "updated_by_id": { 112 "previous": null, 113 "current": 1 114 }, 115 "updated_at": { 116 "previous": "2017-09-15 16:50:55 UTC", 117 "current": "2017-09-15 16:52:00 UTC" 118 }, 119 "labels": { 120 "previous": [{ 121 "id": 206, 122 "title": "API", 123 "color": "#ffffff", 124 "project_id": 14, 125 "created_at": "2013-12-03T17:15:43Z", 126 "updated_at": "2013-12-03T17:15:43Z", 127 "template": false, 128 "description": "API related issues", 129 "type": "ProjectLabel", 130 "group_id": 41 131 }], 132 "current": [{ 133 "id": 205, 134 "title": "Platform", 135 "color": "#123123", 136 "project_id": 14, 137 "created_at": "2013-12-03T17:15:43Z", 138 "updated_at": "2013-12-03T17:15:43Z", 139 "template": false, 140 "description": "Platform related issues", 141 "type": "ProjectLabel", 142 "group_id": 41 143 }] 144 } 145 } 146}

评论事件#

版本历史
  • object_attributes.action 属性于极狐GitLab 16.11 引入。

当在提交、合并请求、议题和代码片段上创建新评论或编辑评论时,会触发评论事件。

笔记数据存储在 object_attributes 中(例如 notenoteable_type)。 负载包含有关评论目标的信息。例如,对议题的评论在 issue 键下包含特定的议题信息。

可用的目标类型包括:

  • commit
  • merge_request
  • issue
  • snippet

负载中 object_attributes.action 的可用值为:

  • create
  • update

对提交的评论#

请求头:

plaintext
X-Gitlab-Event: Note Hook

负载示例:

json
1{ 2 "object_kind": "note", 3 "event_type": "note", 4 "user": { 5 "id": 1, 6 "name": "Administrator", 7 "username": "root", 8 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon", 9 "email": "admin@example.com" 10 }, 11 "project_id": 5, 12 "project":{ 13 "id": 5, 14 "name":"Gitlab Test", 15 "description":"Aut reprehenderit ut est.", 16 "web_url":"http://example.com/gitlabhq/gitlab-test", 17 "avatar_url":null, 18 "git_ssh_url":"git@example.com:gitlabhq/gitlab-test.git", 19 "git_http_url":"http://example.com/gitlabhq/gitlab-test.git", 20 "namespace":"GitlabHQ", 21 "visibility_level":20, 22 "path_with_namespace":"gitlabhq/gitlab-test", 23 "default_branch":"master", 24 "homepage":"http://example.com/gitlabhq/gitlab-test", 25 "url":"http://example.com/gitlabhq/gitlab-test.git", 26 "ssh_url":"git@example.com:gitlabhq/gitlab-test.git", 27 "http_url":"http://example.com/gitlabhq/gitlab-test.git" 28 }, 29 "repository":{ 30 "name": "Gitlab Test", 31 "url": "http://example.com/gitlab-org/gitlab-test.git", 32 "description": "Aut reprehenderit ut est.", 33 "homepage": "http://example.com/gitlab-org/gitlab-test" 34 }, 35 "object_attributes": { 36 "id": 1243, 37 "internal": false, 38 "note": "This is a commit comment. How does this work?", 39 "noteable_type": "Commit", 40 "author_id": 1, 41 "created_at": "2015-05-17 18:08:09 UTC", 42 "updated_at": "2015-05-17 18:08:09 UTC", 43 "project_id": 5, 44 "attachment":null, 45 "line_code": "bec9703f7a456cd2b4ab5fb3220ae016e3e394e3_0_1", 46 "commit_id": "cfe32cf61b73a0d5e9f13e774abde7ff789b1660", 47 "noteable_id": null, 48 "system": false, 49 "st_diff": { 50 "diff": "--- /dev/null\n+++ b/six\n@@ -0,0 +1 @@\n+Subproject commit 409f37c4f05865e4fb208c771485f211a22c4c2d\n", 51 "new_path": "six", 52 "old_path": "six", 53 "a_mode": "0", 54 "b_mode": "160000", 55 "new_file": true, 56 "renamed_file": false, 57 "deleted_file": false 58 }, 59 "action": "create", 60 "url": "http://example.com/gitlab-org/gitlab-test/commit/cfe32cf61b73a0d5e9f13e774abde7ff789b1660#note_1243" 61 }, 62 "commit": { 63 "id": "cfe32cf61b73a0d5e9f13e774abde7ff789b1660", 64 "message": "Add submodule\n\nSigned-off-by: Example User \u003cuser@example.com.com\u003e\n", 65 "timestamp": "2014-02-27T10:06:20+02:00", 66 "url": "http://example.com/gitlab-org/gitlab-test/commit/cfe32cf61b73a0d5e9f13e774abde7ff789b1660", 67 "author": { 68 "name": "Example User", 69 "email": "user@example.com" 70 } 71 } 72}

对合并请求的评论#

请求头:

plaintext
X-Gitlab-Event: Note Hook

负载示例:

json
1{ 2 "object_kind": "note", 3 "event_type": "note", 4 "user": { 5 "id": 1, 6 "name": "Administrator", 7 "username": "root", 8 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon", 9 "email": "admin@example.com" 10 }, 11 "project_id": 5, 12 "project":{ 13 "id": 5, 14 "name":"Gitlab Test", 15 "description":"Aut reprehenderit ut est.", 16 "web_url":"http://example.com/gitlab-org/gitlab-test", 17 "avatar_url":null, 18 "git_ssh_url":"git@example.com:gitlab-org/gitlab-test.git", 19 "git_http_url":"http://example.com/gitlab-org/gitlab-test.git", 20 "namespace":"Gitlab Org", 21 "visibility_level":10, 22 "path_with_namespace":"gitlab-org/gitlab-test", 23 "default_branch":"master", 24 "homepage":"http://example.com/gitlab-org/gitlab-test", 25 "url":"http://example.com/gitlab-org/gitlab-test.git", 26 "ssh_url":"git@example.com:gitlab-org/gitlab-test.git", 27 "http_url":"http://example.com/gitlab-org/gitlab-test.git" 28 }, 29 "repository":{ 30 "name": "Gitlab Test", 31 "url": "http://localhost/gitlab-org/gitlab-test.git", 32 "description": "Aut reprehenderit ut est.", 33 "homepage": "http://example.com/gitlab-org/gitlab-test" 34 }, 35 "object_attributes": { 36 "id": 1244, 37 "internal": false, 38 "note": "This MR needs work.", 39 "noteable_type": "MergeRequest", 40 "author_id": 1, 41 "created_at": "2015-05-17 18:21:36 UTC", 42 "updated_at": "2015-05-17 18:21:36 UTC", 43 "project_id": 5, 44 "attachment": null, 45 "line_code": null, 46 "commit_id": "", 47 "noteable_id": 7, 48 "system": false, 49 "st_diff": null, 50 "action": "create", 51 "url": "http://example.com/gitlab-org/gitlab-test/merge_requests/1#note_1244" 52 }, 53 "merge_request": { 54 "id": 7, 55 "target_branch": "markdown", 56 "source_branch": "master", 57 "source_project_id": 5, 58 "author_id": 8, 59 "assignee_id": 28, 60 "title": "Tempora et eos debitis quae laborum et.", 61 "created_at": "2015-03-01 20:12:53 UTC", 62 "updated_at": "2015-03-21 18:27:27 UTC", 63 "milestone_id": 11, 64 "state": "opened", 65 "merge_status": "cannot_be_merged", 66 "target_project_id": 5, 67 "iid": 1, 68 "description": "Et voluptas corrupti assumenda temporibus. Architecto cum animi eveniet amet asperiores. Vitae numquam voluptate est natus sit et ad id.", 69 "position": 0, 70 "labels": [ 71 { 72 "id": 25, 73 "title": "Afterpod", 74 "color": "#3e8068", 75 "project_id": null, 76 "created_at": "2019-06-05T14:32:20.211Z", 77 "updated_at": "2019-06-05T14:32:20.211Z", 78 "template": false, 79 "description": null, 80 "type": "GroupLabel", 81 "group_id": 4 82 }, 83 { 84 "id": 86, 85 "title": "Element", 86 "color": "#231afe", 87 "project_id": 4, 88 "created_at": "2019-06-05T14:32:20.637Z", 89 "updated_at": "2019-06-05T14:32:20.637Z", 90 "template": false, 91 "description": null, 92 "type": "ProjectLabel", 93 "group_id": null 94 } 95 ], 96 "source":{ 97 "name":"Gitlab Test", 98 "description":"Aut reprehenderit ut est.", 99 "web_url":"http://example.com/gitlab-org/gitlab-test", 100 "avatar_url":null, 101 "git_ssh_url":"git@example.com:gitlab-org/gitlab-test.git", 102 "git_http_url":"http://example.com/gitlab-org/gitlab-test.git", 103 "namespace":"Gitlab Org", 104 "visibility_level":10, 105 "path_with_namespace":"gitlab-org/gitlab-test", 106 "default_branch":"master", 107 "homepage":"http://example.com/gitlab-org/gitlab-test", 108 "url":"http://example.com/gitlab-org/gitlab-test.git", 109 "ssh_url":"git@example.com:gitlab-org/gitlab-test.git", 110 "http_url":"http://example.com/gitlab-org/gitlab-test.git" 111 }, 112 "target": { 113 "name":"Gitlab Test", 114 "description":"Aut reprehenderit ut est.", 115 "web_url":"http://example.com/gitlab-org/gitlab-test", 116 "avatar_url":null, 117 "git_ssh_url":"git@example.com:gitlab-org/gitlab-test.git", 118 "git_http_url":"http://example.com/gitlab-org/gitlab-test.git", 119 "namespace":"Gitlab Org", 120 "visibility_level":10, 121 "path_with_namespace":"gitlab-org/gitlab-test", 122 "default_branch":"master", 123 "homepage":"http://example.com/gitlab-org/gitlab-test", 124 "url":"http://example.com/gitlab-org/gitlab-test.git", 125 "ssh_url":"git@example.com:gitlab-org/gitlab-test.git", 126 "http_url":"http://example.com/gitlab-org/gitlab-test.git" 127 }, 128 "last_commit": { 129 "id": "562e173be03b8ff2efb05345d12df18815438a4b", 130 "message": "Merge branch 'another-branch' into 'master'\n\nCheck in this test\n", 131 "timestamp": "2015-04-08T21: 00:25-07:00", 132 "url": "http://example.com/gitlab-org/gitlab-test/commit/562e173be03b8ff2efb05345d12df18815438a4b", 133 "author": { 134 "name": "John Smith", 135 "email": "john@example.com" 136 } 137 }, 138 "work_in_progress": false, 139 "draft": false, 140 "assignee": { 141 "name": "User1", 142 "username": "user1", 143 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon" 144 }, 145 "detailed_merge_status": "checking" 146 } 147}

对议题的评论#

  • assignee_id 字段已弃用,仅显示第一个指派人。
  • 对于机密议题,event_type 设置为 confidential_note

请求头:

plaintext
X-Gitlab-Event: Note Hook

负载示例:

json
1{ 2 "object_kind": "note", 3 "event_type": "note", 4 "user": { 5 "id": 1, 6 "name": "Administrator", 7 "username": "root", 8 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon", 9 "email": "admin@example.com" 10 }, 11 "project_id": 5, 12 "project":{ 13 "id": 5, 14 "name":"Gitlab Test", 15 "description":"Aut reprehenderit ut est.", 16 "web_url":"http://example.com/gitlab-org/gitlab-test", 17 "avatar_url":null, 18 "git_ssh_url":"git@example.com:gitlab-org/gitlab-test.git", 19 "git_http_url":"http://example.com/gitlab-org/gitlab-test.git", 20 "namespace":"Gitlab Org", 21 "visibility_level":10, 22 "path_with_namespace":"gitlab-org/gitlab-test", 23 "default_branch":"master", 24 "homepage":"http://example.com/gitlab-org/gitlab-test", 25 "url":"http://example.com/gitlab-org/gitlab-test.git", 26 "ssh_url":"git@example.com:gitlab-org/gitlab-test.git", 27 "http_url":"http://example.com/gitlab-org/gitlab-test.git" 28 }, 29 "repository":{ 30 "name":"diaspora", 31 "url":"git@example.com:mike/diaspora.git", 32 "description":"", 33 "homepage":"http://example.com/mike/diaspora" 34 }, 35 "object_attributes": { 36 "id": 1241, 37 "internal": false, 38 "note": "Hello world", 39 "noteable_type": "Issue", 40 "author_id": 1, 41 "created_at": "2015-05-17 17:06:40 UTC", 42 "updated_at": "2015-05-17 17:06:40 UTC", 43 "project_id": 5, 44 "attachment": null, 45 "line_code": null, 46 "commit_id": "", 47 "noteable_id": 92, 48 "system": false, 49 "st_diff": null, 50 "action": "create", 51 "url": "http://example.com/gitlab-org/gitlab-test/issues/17#note_1241" 52 }, 53 "issue": { 54 "id": 92, 55 "title": "test", 56 "assignee_ids": [], 57 "assignee_id": null, 58 "author_id": 1, 59 "project_id": 5, 60 "created_at": "2015-04-12 14:53:17 UTC", 61 "updated_at": "2015-04-26 08:28:42 UTC", 62 "position": 0, 63 "branch_name": null, 64 "description": "test", 65 "milestone_id": null, 66 "state": "closed", 67 "iid": 17, 68 "labels": [ 69 { 70 "id": 25, 71 "title": "Afterpod", 72 "color": "#3e8068", 73 "project_id": null, 74 "created_at": "2019-06-05T14:32:20.211Z", 75 "updated_at": "2019-06-05T14:32:20.211Z", 76 "template": false, 77 "description": null, 78 "type": "GroupLabel", 79 "group_id": 4 80 }, 81 { 82 "id": 86, 83 "title": "Element", 84 "color": "#231afe", 85 "project_id": 4, 86 "created_at": "2019-06-05T14:32:20.637Z", 87 "updated_at": "2019-06-05T14:32:20.637Z", 88 "template": false, 89 "description": null, 90 "type": "ProjectLabel", 91 "group_id": null 92 } 93 ] 94 } 95}

评论代码片段#

请求头:

plaintext
X-Gitlab-Event: Note Hook

负载示例:

json
1{ 2 "object_kind": "note", 3 "event_type": "note", 4 "user": { 5 "id": 1, 6 "name": "Administrator", 7 "username": "root", 8 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon", 9 "email": "admin@example.com" 10 }, 11 "project_id": 5, 12 "project":{ 13 "id": 5, 14 "name":"Gitlab Test", 15 "description":"Aut reprehenderit ut est.", 16 "web_url":"http://example.com/gitlab-org/gitlab-test", 17 "avatar_url":null, 18 "git_ssh_url":"git@example.com:gitlab-org/gitlab-test.git", 19 "git_http_url":"http://example.com/gitlab-org/gitlab-test.git", 20 "namespace":"Gitlab Org", 21 "visibility_level":10, 22 "path_with_namespace":"gitlab-org/gitlab-test", 23 "default_branch":"master", 24 "homepage":"http://example.com/gitlab-org/gitlab-test", 25 "url":"http://example.com/gitlab-org/gitlab-test.git", 26 "ssh_url":"git@example.com:gitlab-org/gitlab-test.git", 27 "http_url":"http://example.com/gitlab-org/gitlab-test.git" 28 }, 29 "repository":{ 30 "name":"Gitlab Test", 31 "url":"http://example.com/gitlab-org/gitlab-test.git", 32 "description":"Aut reprehenderit ut est.", 33 "homepage":"http://example.com/gitlab-org/gitlab-test" 34 }, 35 "object_attributes": { 36 "id": 1245, 37 "internal": false, 38 "note": "Is this snippet doing what it's supposed to be doing?", 39 "noteable_type": "Snippet", 40 "author_id": 1, 41 "created_at": "2015-05-17 18:35:50 UTC", 42 "updated_at": "2015-05-17 18:35:50 UTC", 43 "project_id": 5, 44 "attachment": null, 45 "line_code": null, 46 "commit_id": "", 47 "noteable_id": 53, 48 "system": false, 49 "st_diff": null, 50 "action": "create", 51 "url": "http://example.com/gitlab-org/gitlab-test/-/snippets/53#note_1245" 52 }, 53 "snippet": { 54 "id": 53, 55 "title": "test", 56 "description": "A snippet description.", 57 "content": "puts 'Hello world'", 58 "author_id": 1, 59 "project_id": 5, 60 "created_at": "2015-04-09 02:40:38 UTC", 61 "updated_at": "2015-04-09 02:40:38 UTC", 62 "file_name": "test.rb", 63 "type": "ProjectSnippet", 64 "visibility_level": 0, 65 "url": "http://example.com/gitlab-org/gitlab-test/-/snippets/53" 66 } 67}

合并请求事件#

当以下情况发生时,合并请求事件被触发:

  • 创建新的合并请求。
  • 现有合并请求被更新、批准(由所有必需的审批者)、取消批准、合并或关闭。
  • 单个用户添加或移除其对现有合并请求的批准。
  • 审查者被重新请求审查合并请求。
  • 提交被添加到源分支。
  • 合并请求上的所有讨论都已解决。

即使 changes 字段为空,合并请求事件也可能被触发。 Webhook 接收者应始终检查 changes 字段的内容以获取合并请求的实际更改。

负载结构#

Webhook 负载的 JSON 结构在所有操作类型中是一致的。 差异在于哪些字段包含数据,以及是否存在诸如 oldrevsystemsystem_action 之类的条件字段。

负载中 object_attributes.action 的可用值为:

  • open:合并请求已创建。
  • close:合并请求已关闭。
  • reopen:已关闭的合并请求被重新打开。
  • update:合并请求已更新。这包括常规更新和重新请求审查操作。请检查 changes 字段以确定具体的更新类型。
  • approval:用户添加了其批准。
  • approved:合并请求已被所有必需的审批者完全批准。
  • unapproval:用户移除了其批准,无论是手动还是由系统执行。
  • unapproved:先前批准的合并请求失去了其批准状态,无论是手动还是由系统执行。
  • merge:合并请求已合并。

合并请求 webhook 负载包含以下顶级字段:

字段类型描述
object_kindString"merge_request"
event_typeString"merge_request"
userObject触发事件的用户。
projectObject目标项目。
object_attributesObject合并请求数据。
changesObject包含操作期间更改的属性。
assigneesArray当前指派的用户。
reviewersArray当前指派的审查者。
labelsArray标签对象。
repositoryObject已弃用。请改用 project。代码仓信息。

已弃用字段#

以下字段已弃用,仅为向后兼容而保留。请改用推荐的替代方案:

已弃用字段推荐替代方案
object_attributes.assignee_idobject_attributes.assignee_ids
object_attributes.work_in_progressobject_attributes.draft
project.http_urlproject.git_http_url
project.homepageproject.web_url
project.ssh_urlproject.git_ssh_url
project.urlproject.git_ssh_urlproject.git_http_url
repositoryproject

object_attributes 字段#

版本历史
  • 引入于 极狐GitLab 18.10。

object_attributes 字段包含合并请求的当前状态。 它包含以下字段:

字段类型描述
actionString触发 webhook 的操作。例如,openupdatemerge
actioned_atString触发 webhook 的操作发生的时间。
approval_rulesArray审批规则对象数组(仅限企业版)。
assignee_idsArray指派人 ID 的数组。
author_idInteger合并请求作者的 ID。
blocking_discussions_resolvedBoolean阻塞讨论是否已解决。
created_atString合并请求的创建时间。
descriptionString合并请求描述。
detailed_merge_statusString详细的合并状态信息。有关可能值的列表,请参见合并状态
draftBoolean合并请求是否为草稿。
first_contributionBoolean这是否是作者的首次贡献。
head_pipeline_idInteger头流水线的 ID。
human_time_changeString人类可读的时间变更。
human_time_estimateString人类可读的时间预估。
human_total_time_spentString人类可读的总花费时间。
idInteger合并请求 ID。
iidInteger合并请求的内部 ID。
labelsArray标签对象数组。
last_commitObject包含详细信息的最后一次提交对象。
last_edited_atString合并请求的最后编辑时间。
last_edited_by_idInteger最后编辑用户的 ID。
merge_commit_shaString合并提交的 SHA。
merge_errorString任何合并错误消息。
merge_paramsObject合并参数。
merge_statusString合并请求的状态。
merge_user_idInteger合并用户的 ID。
merge_when_pipeline_succeedsBoolean是否启用了自动合并。
milestone_idInteger里程碑的 ID。
oldrevString旧提交的 SHA(仅在推送相关事件中存在)。
prepared_atString合并请求准备完成的时间戳。此字段仅在所有准备步骤完成后填充一次,并且如果添加了更多更改也不会更新。
reviewer_idsArray审查者 ID 的数组。
source_branchString源分支名称。
sourceObject源项目的详细信息。例如,名称和描述。
source_project_idInteger源项目的 ID。
squash_commit_shaString压缩提交的 SHA。仅在合并请求以压缩方式合并时存在。
state_idInteger状态 ID(1:已打开,2:已关闭,3:已合并,4:已锁定)。
stateString合并请求的状态(openedclosedmergedlocked)。
system_actionString系统操作(仅在 systemtrue 时存在)。
systemBoolean事件是否由系统发起。
target_branchString目标分支名称。
targetObject目标项目的详细信息。例如,名称和描述。
target_project_idInteger目标项目的 ID。
time_changeInteger花费时间的变更(以秒为单位)。
time_estimateInteger时间预估(以秒为单位)。
titleString合并请求标题。
total_time_spentInteger总花费时间(以秒为单位)。
updated_atString合并请求的最后更新时间。
updated_by_idInteger最后更新用户的 ID。
urlString合并请求的 URL。

changes 字段#

changes 字段仅包含在操作期间修改过的字段。 并非 object_attributes 中的所有字段都会出现在 changes 中。

每个更改的字段都遵循此格式:

json
1{ 2 "field_name": { 3 "previous": "old_value", 4 "current": "new_value" 5 } 6}

属性#

  • assignees
  • blocking_discussions_resolved
  • description
  • draft
  • head_pipeline_id
  • labels
  • last_edited_at
  • last_edited_by_id
  • merge_commit_sha
  • merge_error
  • merge_params
  • merge_status
  • merge_user_id
  • merge_when_pipeline_succeeds
  • milestone_id
  • prepared_at
  • reviewer_ids
  • reviewers
  • squash_commit_sha
  • state_id
  • target_branch
  • time_change
  • time_estimate
  • title
  • total_time_spent
  • updated_at
  • updated_by_id

合并请求操作特定字段#

object_attributes.oldrev 字段仅在存在实际代码更改的 update 操作中可用,例如:

  • 新代码被推送到源分支。
  • 应用了建议

以下示例显示了一个包含 oldrevupdate 事件(部分负载):

json
1{ 2 "object_kind": "merge_request", 3 "event_type": "merge_request", 4 "object_attributes": { 5 "action": "update", 6 "oldrev": "e59094b8de0f2f91abbe4760a52d9137260252d8" 7 } 8}

系统发起的合并请求事件#

某些合并请求事件是由系统自动触发的,例如由于新提交推送导致审批被重置时。这些系统发起的 webhook 事件仅由推送事件触发,并在负载中包含更多字段:

  • object_attributes.system:布尔值字段。如果为 true,则事件由系统触发。如果为 false,则是由用户操作触发的事件。

  • object_attributes.system_action:字符串字段,仅在 systemtrue 时存在。提供有关系统操作的更多上下文。可用值为:

    • approvals_reset_on_push:项目已启用推送时重置审批,并且推送了新的提交。
    • code_owner_approvals_reset_on_push:项目已启用选择性代码所有者移除,并且由于文件更改匹配 CODEOWNERS 规则而重置了代码所有者审批。

其他审批重置场景不会触发 webhook。

以下示例显示了一个系统发起的事件(部分负载):

json
1{ 2 "object_kind": "merge_request", 3 "event_type": "merge_request", 4 "object_attributes": { 5 "action": "update", 6 "system": true, 7 "system_action": "approvals_reset_on_push" 8 } 9}

审查者状态跟踪#

合并请求 webhook 负载中的 reviewers 数组包含每个审查者的 state 字段。state 字段指示审查者的当前审查状态:

  • unreviewed:审查者尚未审查合并请求
  • review_started:审查者已开始审查但尚未完成
  • reviewed:审查者已完成审查
  • requested_changes:审查者已要求进行更改
  • approved:审查者已批准合并请求
  • unapproved:审查者先前已批准,但其批准已被移除

以下示例显示了一个审查者数组(部分负载):

json
1{ 2 "reviewers": [ 3 { 4 "id": 6, 5 "name": "User1", 6 "username": "user1", 7 "state": "unreviewed", 8 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", 9 "email": "user1@example.com" 10 } 11 ] 12}

重新请求审查事件#

当为合并请求重新请求审查者时,会触发一个包含 action: "update" 的 webhook,并在 changes 对象中提供增强信息。更改负载包括:

  • 先前状态(第一个数组):显示重新请求前审查者的状态,其中 re_requested: false
  • 当前状态(第二个数组):显示重新请求后审查者更新后的状态,对于被重新请求的审查者,re_requested: true
  • 状态转换:演示审查者的状态如何更改(例如,从 approved 变为 unreviewed

以下示例显示了重新请求审查的变更(部分负载):

json
1{ 2 "object_kind": "merge_request", 3 "event_type": "merge_request", 4 "object_attributes": { 5 "action": "update" 6 }, 7 "changes": { 8 "reviewers": [ 9 [ 10 { 11 "id": 6, 12 "name": "User1", 13 "username": "user1", 14 "state": "approved", 15 "re_requested": false, 16 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", 17 "email": "user1@example.com" 18 } 19 ], 20 [ 21 { 22 "id": 6, 23 "name": "User1", 24 "username": "user1", 25 "state": "unreviewed", 26 "re_requested": true, 27 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", 28 "email": "user1@example.com" 29 } 30 ] 31 ] 32 } 33}

完整负载示例#

请求头:

plaintext
X-Gitlab-Event: Merge Request Hook

以下是一个 open 操作的完整合并请求 webhook 负载示例。 为清晰起见,省略了已弃用的字段。有关已弃用字段及其推荐替代方案的列表,请参见已弃用字段

json
1{ 2 "object_kind": "合并请求", 3 "event_type": "合并请求", 4 "user": { 5 "id": 1, 6 "name": "Alex Garcia", 7 "username": "agarcia", 8 "avatar_url": "https://www.gravatar.com/avatar/1a29da0ccd099482194440fac762f5ccb4ec53227761d1859979367644a889a5?s=80&d=identicon", 9 "email": "agarcia@example.com" 10 }, 11 "project": { 12 "id": 2, 13 "name": "飞行管理", 14 "description": "用于跟踪飞机状态的飞行管理应用程序。", 15 "web_url": "http://gitlab.example.com/flightjs/flight-management", 16 "avatar_url": null, 17 "git_ssh_url": "ssh://git@gitlab.example.com:flightjs/flight-management.git", 18 "git_http_url": "http://gitlab.example.com/flightjs/flight-management.git", 19 "namespace": "Flightjs", 20 "visibility_level": 0, 21 "path_with_namespace": "flightjs/flight-management", 22 "default_branch": "main", 23 "ci_config_path": null 24 }, 25 "object_attributes": { 26 "author_id": 1, 27 "created_at": "2026-01-16 05:56:22 UTC", 28 "description": "此合并请求为预订表单添加了输入验证。", 29 "draft": false, 30 "head_pipeline_id": null, 31 "id": 93, 32 "iid": 16, 33 "last_edited_at": null, 34 "last_edited_by_id": null, 35 "merge_commit_sha": null, 36 "merge_error": null, 37 "merge_params": { 38 "force_remove_source_branch": "1" 39 }, 40 "merge_status": "检查中", 41 "merge_user_id": null, 42 "merge_when_pipeline_succeeds": false, 43 "milestone_id": 8, 44 "source_branch": "feature/booking-validation", 45 "source_project_id": 2, 46 "squash_commit_sha": null, 47 "state_id": 1, 48 "target_branch": "main", 49 "target_project_id": 2, 50 "time_estimate": 0, 51 "title": "为预订表单添加输入验证", 52 "updated_at": "2026-01-16 05:56:25 UTC", 53 "updated_by_id": null, 54 "prepared_at": "2026-01-16 05:56:25 UTC", 55 "assignee_ids": [ 56 1 57 ], 58 "blocking_discussions_resolved": true, 59 "detailed_merge_status": "检查中", 60 "first_contribution": true, 61 "human_time_change": null, 62 "human_time_estimate": null, 63 "human_total_time_spent": null, 64 "labels": [ 65 { 66 "id": 19, 67 "title": "增强", 68 "color": "#adb21a", 69 "project_id": null, 70 "created_at": "2026-01-07 00:03:52 UTC", 71 "updated_at": "2026-01-07 00:03:52 UTC", 72 "template": false, 73 "description": null, 74 "type": "群组标签", 75 "group_id": 24 76 } 77 ], 78 "last_commit": { 79 "id": "e59094b8de0f2f91abbe4760a52d9137260252d8", 80 "message": "添加电子邮件格式验证", 81 "title": "添加电子邮件格式验证", 82 "timestamp": "2026-01-16T05:01:10+00:00", 83 "url": "http://gitlab.example.com/flightjs/flight-management/-/commit/e59094b8de0f2f91abbe4760a52d9137260252d8", 84 "author": { 85 "name": "Alex Garcia", 86 "email": "agarcia@example.com" 87 } 88 }, 89 "reviewer_ids": [ 90 25 91 ], 92 "source": { 93 "id": 2, 94 "name": "飞行管理", 95 "description": "用于跟踪飞机状态的飞行管理应用程序。", 96 "web_url": "http://gitlab.example.com/flightjs/flight-management", 97 "avatar_url": null, 98 "git_ssh_url": "ssh://git@gitlab.example.com:flightjs/flight-management.git", 99 "git_http_url": "http://gitlab.example.com/flightjs/flight-management.git", 100 "namespace": "Flightjs", 101 "visibility_level": 0, 102 "path_with_namespace": "flightjs/flight-management", 103 "default_branch": "main", 104 "ci_config_path": null 105 }, 106 "state": "已打开", 107 "system": false, 108 "target": { 109 "id": 2, 110 "name": "飞行管理", 111 "description": "用于跟踪飞机状态的飞行管理应用程序。", 112 "web_url": "http://gitlab.example.com/flightjs/flight-management", 113 "avatar_url": null, 114 "git_ssh_url": "ssh://git@gitlab.example.com:flightjs/flight-management.git", 115 "git_http_url": "http://gitlab.example.com/flightjs/flight-management.git", 116 "namespace": "Flightjs", 117 "visibility_level": 0, 118 "path_with_namespace": "flightjs/flight-management", 119 "default_branch": "main", 120 "ci_config_path": null 121 }, 122 "time_change": 0, 123 "total_time_spent": 0, 124 "url": "http://gitlab.example.com/flightjs/flight-management/-/merge_requests/16", 125 "approval_rules": [ 126 { 127 "id": 4, 128 "approvals_required": 0, 129 "name": "所有成员", 130 "rule_type": "任意审批人", 131 "report_type": null, 132 "merge_request_id": 93, 133 "section": null, 134 "modified_from_project_rule": false, 135 "orchestration_policy_idx": null, 136 "vulnerabilities_allowed": 0, 137 "scanners": [], 138 "severity_levels": [], 139 "vulnerability_states": [ 140 "new_needs_triage", 141 "new_dismissed" 142 ], 143 "security_orchestration_policy_configuration_id": null, 144 "scan_result_policy_id": null, 145 "applicable_post_merge": null, 146 "project_id": 2, 147 "approval_policy_rule_id": null, 148 "updated_at": "2026-01-16 05:56:22 UTC", 149 "created_at": "2026-01-16 05:56:22 UTC" 150 } 151 ], 152 "action": "打开", 153 "actioned_at": "2026-01-16 05:56:26 UTC" 154 }, 155 "labels": [ 156 { 157 "id": 19, 158 "title": "增强", 159 "color": "#adb21a", 160 "project_id": null, 161 "created_at": "2026-01-07 00:03:52 UTC", 162 "updated_at": "2026-01-07 00:03:52 UTC", 163 "template": false, 164 "description": null, 165 "type": "群组标签", 166 "group_id": 24 167 } 168 ], 169 "changes": { 170 "merge_status": { 171 "previous": "准备中", 172 "current": "检查中" 173 }, 174 "updated_at": { 175 "previous": "2026-01-16 05:56:22 UTC", 176 "current": "2026-01-16 05:56:25 UTC" 177 }, 178 "prepared_at": { 179 "previous": null, 180 "current": "2026-01-16 05:56:25 UTC" 181 } 182 }, 183 "assignees": [ 184 { 185 "id": 1, 186 "name": "Alex Garcia", 187 "username": "agarcia", 188 "avatar_url": "https://www.gravatar.com/avatar/1a29da0ccd099482194440fac762f5ccb4ec53227761d1859979367644a889a5?s=80&d=identicon", 189 "email": "[已编辑]" 190 } 191 ], 192 "reviewers": [ 193 { 194 "id": 25, 195 "name": "Sidney Jones", 196 "username": "sjones", 197 "avatar_url": "https://www.gravatar.com/avatar/1be419860e7f852e20ca2691e6b55949f7809177e7765181da42e4448491e367?s=80&d=identicon", 198 "email": "[已编辑]", 199 "state": "未评审", 200 "re_requested": false 201 } 202 ] 203}
字段 `assignee_id` 和 `merge_status` 已[弃用](../../../api/merge_requests.md)。

Wiki 页面事件#

当 wiki 页面被创建、更新或删除时,会触发 Wiki 页面事件。

请求头:

plaintext
X-Gitlab-Event: Wiki Page Hook

Payload 示例:

json
1{ 2 "object_kind": "wiki_page", 3 "user": { 4 "id": 1, 5 "name": "管理员", 6 "username": "root", 7 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon", 8 "email": "admin@example.com" 9 }, 10 "project": { 11 "id": 1, 12 "name": "awesome-project", 13 "description": "这太棒了", 14 "web_url": "http://example.com/root/awesome-project", 15 "avatar_url": null, 16 "git_ssh_url": "git@example.com:root/awesome-project.git", 17 "git_http_url": "http://example.com/root/awesome-project.git", 18 "namespace": "root", 19 "visibility_level": 0, 20 "path_with_namespace": "root/awesome-project", 21 "default_branch": "master", 22 "homepage": "http://example.com/root/awesome-project", 23 "url": "git@example.com:root/awesome-project.git", 24 "ssh_url": "git@example.com:root/awesome-project.git", 25 "http_url": "http://example.com/root/awesome-project.git" 26 }, 27 "wiki": { 28 "web_url": "http://example.com/root/awesome-project/-/wikis/home", 29 "git_ssh_url": "git@example.com:root/awesome-project.wiki.git", 30 "git_http_url": "http://example.com/root/awesome-project.wiki.git", 31 "path_with_namespace": "root/awesome-project.wiki", 32 "default_branch": "master" 33 }, 34 "object_attributes": { 35 "title": "Awesome", 36 "content": "精彩内容在此", 37 "format": "markdown", 38 "message": "向 wiki 添加一个精彩的页面", 39 "slug": "awesome", 40 "url": "http://example.com/root/awesome-project/-/wikis/awesome", 41 "action": "创建", 42 "diff_url": "http://example.com/root/awesome-project/-/wikis/home/diff?version_id=78ee4a6705abfbff4f4132c6646dbaae9c8fb6ec", 43 "version_id": "3ad67c972065298d226dd80b2b03e0fc2421e731" 44 } 45}

流水线事件#

当流水线状态发生变化时,会触发流水线事件。

在极狐GitLab 15.1 及更高版本中,被屏蔽用户触发的流水线 webhook 不会被处理。

在极狐GitLab 16.1 及更高版本中,流水线 webhook 开始暴露 object_attributes.name

请求头:

plaintext
X-Gitlab-Event: Pipeline Hook

Payload 示例:

json
1{ 2 "object_kind": "流水线", 3 "object_attributes": { 4 "id": 31, 5 "iid": 3, 6 "name": "分支 master 的流水线", 7 "ref": "master", 8 "tag": false, 9 "sha": "bcbb5ec396a2c0f828686f14fac9b80b780504f2", 10 "before_sha": "bcbb5ec396a2c0f828686f14fac9b80b780504f2", 11 "source": "合并请求事件", 12 "status": "成功", 13 "detailed_status": "已通过", 14 "stages": [ 15 "构建", 16 "测试", 17 "部署" 18 ], 19 "created_at": "2016-08-12 15:23:28 UTC", 20 "finished_at": "2016-08-12 15:26:29 UTC", 21 "duration": 63, 22 "queued_duration": 10, 23 "variables": [ 24 { 25 "key": "NESTOR_PROD_ENVIRONMENT", 26 "value": "us-west-1" 27 } 28 ], 29 "url": "http://example.com/gitlab-org/gitlab-test/-/pipelines/31" 30 }, 31 "merge_request": { 32 "id": 1, 33 "iid": 1, 34 "title": "测试", 35 "source_branch": "test", 36 "source_project_id": 1, 37 "target_branch": "master", 38 "target_project_id": 1, 39 "state": "已打开", 40 "merge_status": "可以合并", 41 "detailed_merge_status": "可合并", 42 "url": "http://192.168.64.1:3005/gitlab-org/gitlab-test/merge_requests/1" 43 }, 44 "user": { 45 "id": 1, 46 "name": "管理员", 47 "username": "root", 48 "avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon", 49 "email": "user_email@gitlab.com" 50 }, 51 "project": { 52 "id": 1, 53 "name": "Gitlab 测试", 54 "description": "Atque in sunt eos similique dolores voluptatem.", 55 "web_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test", 56 "avatar_url": null, 57 "git_ssh_url": "git@192.168.64.1:gitlab-org/gitlab-test.git", 58 "git_http_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test.git", 59 "namespace": "Gitlab Org", 60 "visibility_level": 20, 61 "path_with_namespace": "gitlab-org/gitlab-test", 62 "default_branch": "master", 63 "ci_config_path": null 64 }, 65 "commit": { 66 "id": "bcbb5ec396a2c0f828686f14fac9b80b780504f2", 67 "message": "test\n", 68 "title": "测试", 69 "timestamp": "2016-08-12T17:23:21+02:00", 70 "url": "http://example.com/gitlab-org/gitlab-test/commit/bcbb5ec396a2c0f828686f14fac9b80b780504f2", 71 "author": { 72 "name": "用户", 73 "email": "user@gitlab.com" 74 } 75 }, 76 "builds": [ 77 { 78 "id": 380, 79 "stage": "部署", 80 "name": "生产环境", 81 "status": "已跳过", 82 "created_at": "2016-08-12 15:23:28 UTC", 83 "started_at": null, 84 "finished_at": null, 85 "duration": null, 86 "queued_duration": null, 87 "failure_reason": null, 88 "when": "手动", 89 "manual": true, 90 "allow_failure": false, 91 "user": { 92 "id": 1, 93 "name": "管理员", 94 "username": "root", 95 "avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon", 96 "email": "admin@example.com" 97 }, 98 "runner": null, 99 "artifacts_file": { 100 "filename": null, 101 "size": null 102 }, 103 "environment": { 104 "name": "生产环境", 105 "action": "开始", 106 "deployment_tier": "生产环境" 107 } 108 }, 109 { 110 "id": 377, 111 "stage": "测试", 112 "name": "测试镜像", 113 "status": "成功", 114 "created_at": "2016-08-12 15:23:28 UTC", 115 "started_at": "2016-08-12 15:26:12 UTC", 116 "finished_at": "2016-08-12 15:26:29 UTC", 117 "duration": 17.0, 118 "queued_duration": 196.0, 119 "failure_reason": null, 120 "when": "成功时", 121 "manual": false, 122 "allow_failure": false, 123 "user": { 124 "id": 1, 125 "name": "管理员", 126 "username": "root", 127 "avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon", 128 "email": "admin@example.com" 129 }, 130 "runner": { 131 "id": 380987, 132 "description": "shared-runners-manager-6.gitlab.com", 133 "runner_type": "实例类型", 134 "active": true, 135 "is_shared": true, 136 "tags": [ 137 "linux", 138 "docker", 139 "shared-runner" 140 ] 141 }, 142 "artifacts_file": { 143 "filename": null, 144 "size": null 145 }, 146 "environment": null 147 }, 148 { 149 "id": 378, 150 "stage": "测试", 151 "name": "测试构建", 152 "status": "失败", 153 "created_at": "2016-08-12 15:23:28 UTC", 154 "started_at": "2016-08-12 15:26:12 UTC", 155 "finished_at": "2016-08-12 15:26:29 UTC", 156 "duration": 17.0, 157 "queued_duration": 196.0, 158 "failure_reason": "脚本失败", 159 "when": "成功时", 160 "manual": false, 161 "allow_failure": false, 162 "user": { 163 "id": 1, 164 "name": "管理员", 165 "username": "root", 166 "avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon", 167 "email": "admin@example.com" 168 }, 169 "runner": { 170 "id": 380987, 171 "description": "shared-runners-manager-6.gitlab.com", 172 "runner_type": "实例类型", 173 "active": true, 174 "is_shared": true, 175 "tags": [ 176 "linux", 177 "docker" 178 ] 179 }, 180 "artifacts_file": { 181 "filename": null, 182 "size": null 183 }, 184 "environment": null 185 }, 186 { 187 "id": 376, 188 "stage": "构建", 189 "name": "构建镜像", 190 "status": "成功", 191 "created_at": "2016-08-12 15:23:28 UTC", 192 "started_at": "2016-08-12 15:24:56 UTC", 193 "finished_at": "2016-08-12 15:25:26 UTC", 194 "duration": 17.0, 195 "queued_duration": 196.0, 196 "failure_reason": null, 197 "when": "成功时", 198 "manual": false, 199 "allow_failure": false, 200 "user": { 201 "id": 1, 202 "name": "管理员", 203 "username": "root", 204 "avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon", 205 "email": "admin@example.com" 206 }, 207 "runner": { 208 "id": 380987, 209 "description": "shared-runners-manager-6.gitlab.com", 210 "runner_type": "实例类型", 211 "active": true, 212 "is_shared": true, 213 "tags": [ 214 "linux", 215 "docker" 216 ] 217 }, 218 "artifacts_file": { 219 "filename": null, 220 "size": null 221 }, 222 "environment": null 223 }, 224 { 225 "id": 379, 226 "stage": "部署", 227 "name": "预发布环境", 228 "status": "已创建", 229 "created_at": "2016-08-12 15:23:28 UTC", 230 "started_at": null, 231 "finished_at": null, 232 "duration": null, 233 "queued_duration": null, 234 "failure_reason": null, 235 "when": "成功时", 236 "manual": false, 237 "allow_failure": false, 238 "user": { 239 "id": 1, 240 "name": "管理员", 241 "username": "root", 242 "avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon", 243 "email": "admin@example.com" 244 }, 245 "runner": null, 246 "artifacts_file": { 247 "filename": null, 248 "size": null 249 }, 250 "environment": { 251 "name": "预发布环境", 252 "action": "开始", 253 "deployment_tier": "预发布环境" 254 } 255 } 256 ], 257 "source_pipeline": { 258 "project": { 259 "id": 41, 260 "web_url": "https://gitlab.example.com/gitlab-org/upstream-project", 261 "path_with_namespace": "gitlab-org/upstream-project" 262 }, 263 "pipeline_id": 30, 264 "job_id": 3401 265 } 266}

作业事件#

当作业状态发生变化时,会触发作业事件。触发器作业除外。

payload 中的 commit.id 是流水线的 ID,而不是提交的 ID。

在极狐GitLab 15.1 及更高版本中,被屏蔽用户触发的作业事件不会被处理。

请求头:

plaintext
X-Gitlab-Event: Job Hook

Payload 示例:

json
1{ 2 "object_kind": "构建", 3 "ref": "gitlab-script-trigger", 4 "tag": false, 5 "before_sha": "2293ada6b400935a1378653304eaf6221e0fdb8f", 6 "sha": "2293ada6b400935a1378653304eaf6221e0fdb8f", 7 "retries_count": 2, 8 "build_id": 1977, 9 "build_name": "测试", 10 "build_stage": "测试", 11 "build_status": "已创建", 12 "build_created_at": "2021-02-23T02:41:37.886Z", 13 "build_started_at": null, 14 "build_finished_at": null, 15 "build_created_at_iso": "2021-02-23T02:41:37Z", 16 "build_started_at_iso": null, 17 "build_finished_at_iso": null, 18 "build_duration": null, 19 "build_queued_duration": 1095.588715, 20 "build_allow_failure": false, 21 "build_failure_reason": "未知失败", 22 "pipeline_id": 2366, 23 "runner": { 24 "id": 380987, 25 "description": "shared-runners-manager-6.gitlab.com", 26 "runner_type": "项目类型", 27 "active": true, 28 "is_shared": false, 29 "tags": [ 30 "linux", 31 "docker" 32 ] 33 }, 34 "project_id": 380, 35 "project_name": "gitlab-org/gitlab-test", 36 "user": { 37 "id": 3, 38 "name": "用户", 39 "username": "user", 40 "avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon", 41 "email": "user@gitlab.com" 42 }, 43 "commit": { 44 "id": 2366, 45 "name": "构建流水线", 46 "sha": "2293ada6b400935a1378653304eaf6221e0fdb8f", 47 "message": "test\n", 48 "author_name": "用户", 49 "author_email": "user@gitlab.com", 50 "author_url": "http://192.168.64.1:3005/user", 51 "status": "已创建", 52 "duration": null, 53 "started_at": null, 54 "finished_at": null, 55 "started_at_iso": null, 56 "finished_at_iso": null 57 }, 58 "repository": { 59 "name": "gitlab_test", 60 "url": "http://192.168.64.1:3005/gitlab-org/gitlab-test", 61 "description": "Atque in sunt eos similique dolores voluptatem.", 62 "homepage": "http://192.168.64.1:3005/gitlab-org/gitlab-test", 63 "git_ssh_url": "git@192.168.64.1:gitlab-org/gitlab-test.git", 64 "git_http_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test.git", 65 "visibility_level": 20 66 }, 67 "project": { 68 "id": 380, 69 "name": "Gitlab 测试", 70 "description": "Atque in sunt eos similique dolores voluptatem.", 71 "web_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test", 72 "avatar_url": null, 73 "git_ssh_url": "git@192.168.64.1:gitlab-org/gitlab-test.git", 74 "git_http_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test.git", 75 "namespace": "Gitlab Org", 76 "visibility_level": 20, 77 "path_with_namespace": "gitlab-org/gitlab-test", 78 "default_branch": "master", 79 "ci_config_path": null 80 }, 81 "environment": null, 82 "source_pipeline": { 83 "project": { 84 "id": 41, 85 "web_url": "https://gitlab.example.com/gitlab-org/upstream-project", 86 "path_with_namespace": "gitlab-org/upstream-project" 87 }, 88 "pipeline_id": 30, 89 "job_id": 3401 90 } 91}

重试次数#

版本历史
  • retries_count 在极狐GitLab 15.6 中引入,带有一个功能标志 名为 job_webhook_retries_count。默认禁用。
  • retries_count 在极狐GitLab 16.2 中于私有化部署实例上启用。

retries_count 是一个整数,表示作业是否为重试。0 表示该作业尚未重试。1 表示这是第一次重试。

流水线名称#

版本历史
  • commit.name 在极狐GitLab 15.8 中引入。

你可以使用 workflow:name 为流水线设置自定义名称。如果流水线有名称,则该名称就是 commit.name 的值。

部署事件#

当部署出现以下情况时,会触发部署事件:

  • 开始
  • 成功
  • 失败
  • 被取消

payload 中的 deployable_iddeployable_url 代表执行部署的 CI/CD 作业。当部署事件通过 APItrigger 作业 发生时,deployable_urlnull

请求头:

plaintext
X-Gitlab-Event: Deployment Hook

Payload 示例:

json
1{ 2 "object_kind": "部署", 3 "status": "成功", 4 "status_changed_at":"2021-04-28 21:50:00 +0200", 5 "deployment_id": 15, 6 "deployable_id": 796, 7 "deployable_url": "http://10.126.0.2:3000/root/test-deployment-webhooks/-/jobs/796", 8 "environment": "预发布环境", 9 "environment_tier": "预发布环境", 10 "environment_slug": "staging", 11 "environment_external_url": "https://staging.example.com", 12 "project": { 13 "id": 30, 14 "name": "test-deployment-webhooks", 15 "description": "", 16 "web_url": "http://10.126.0.2:3000/root/test-deployment-webhooks", 17 "avatar_url": null, 18 "git_ssh_url": "ssh://vlad@10.126.0.2:2222/root/test-deployment-webhooks.git", 19 "git_http_url": "http://10.126.0.2:3000/root/test-deployment-webhooks.git", 20 "namespace": "管理员", 21 "visibility_level": 0, 22 "path_with_namespace": "root/test-deployment-webhooks", 23 "default_branch": "master", 24 "ci_config_path": "", 25 "homepage": "http://10.126.0.2:3000/root/test-deployment-webhooks", 26 "url": "ssh://vlad@10.126.0.2:2222/root/test-deployment-webhooks.git", 27 "ssh_url": "ssh://vlad@10.126.0.2:2222/root/test-deployment-webhooks.git", 28 "http_url": "http://10.126.0.2:3000/root/test-deployment-webhooks.git" 29 }, 30 "short_sha": "279484c0", 31 "user": { 32 "id": 1, 33 "name": "管理员", 34 "username": "root", 35 "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", 36 "email": "admin@example.com" 37 }, 38 "user_url": "http://10.126.0.2:3000/root", 39 "commit_url": "http://10.126.0.2:3000/root/test-deployment-webhooks/-/commit/279484c09fbe69ededfced8c1bb6e6d24616b468", 40 "commit_title": "添加新文件" 41}

群组成员事件#

Tier: 专业版,旗舰版

版本历史
  • 访问请求事件在极狐GitLab 17.4 中引入。

这些事件仅针对群组 webhook 触发。

成员事件在以下情况触发:

  • 用户被添加为群组成员。
  • 用户的访问级别发生变化。
  • 用户访问的到期日期更新。
  • 用户从群组中移除。
  • 用户请求访问群组。
  • 访问请求被拒绝。

添加成员到群组#

请求头:

plaintext
X-Gitlab-Event: Member Hook

Payload 示例:

json
1{ 2 "created_at": "2020-12-11T04:57:22Z", 3 "updated_at": "2020-12-11T04:57:22Z", 4 "group_name": "webhook-test", 5 "group_path": "webhook-test", 6 "group_id": 100, 7 "user_username": "test_user", 8 "user_name": "测试用户", 9 "user_email": "testuser@webhooktest.com", 10 "user_id": 64, 11 "group_access": "访客", 12 "group_plan": null, 13 "expires_at": "2020-12-14T00:00:00Z", 14 "event_name": "用户添加到群组" 15}

更新成员访问级别或到期日期#

请求头:

plaintext
X-Gitlab-Event: Member Hook

Payload 示例:

json
1{ 2 "created_at": "2020-12-11T04:57:22Z", 3 "updated_at": "2020-12-12T08:48:19Z", 4 "group_name": "webhook-test", 5 "group_path": "webhook-test", 6 "group_id": 100, 7 "user_username": "test_user", 8 "user_name": "测试用户", 9 "user_email": "testuser@webhooktest.com", 10 "user_id": 64, 11 "group_access": "开发者", 12 "group_plan": null, 13 "expires_at": "2020-12-20T00:00:00Z", 14 "event_name": "群组用户更新" 15}

从群组移除成员#

请求头:

plaintext
X-Gitlab-Event: Member Hook

Payload 示例:

json
1{ 2 "created_at": "2020-12-11T04:57:22Z", 3 "updated_at": "2020-12-12T08:52:34Z", 4 "group_name": "webhook-test", 5 "group_path": "webhook-test", 6 "group_id": 100, 7 "user_username": "test_user", 8 "user_name": "测试用户", 9 "user_email": "testuser@webhooktest.com", 10 "user_id": 64, 11 "group_access": "访客", 12 "group_plan": null, 13 "expires_at": "2020-12-14T00:00:00Z", 14 "event_name": "用户从群组移除" 15}

用户请求访问#

版本历史
  • 在极狐GitLab 17.4 中引入,当时以一个功能标志启用,命名为 group_access_request_webhooks。默认禁用。
  • 在极狐GitLab 17.5 中全面可用。功能标志 group_access_request_webhooks 已移除。

请求头:

plaintext
X-Gitlab-Event: Member Hook

负载示例:

json
1{ 2 "created_at": "2020-12-11T04:57:22Z", 3 "updated_at": "2020-12-12T08:52:34Z", 4 "group_name": "webhook-test", 5 "group_path": "webhook-test", 6 "group_id": 100, 7 "user_username": "test_user", 8 "user_name": "Test User", 9 "user_email": "testuser@webhooktest.com", 10 "user_id": 64, 11 "group_access": "Guest", 12 "group_plan": null, 13 "expires_at": "2020-12-14T00:00:00Z", 14 "event_name": "user_access_request_to_group" 15}

访问请求被拒绝#

版本历史
  • 在极狐GitLab 17.4 中引入,当时以一个功能标志启用,命名为 group_access_request_webhooks。默认禁用。
  • 在极狐GitLab 17.5 中全面可用。功能标志 group_access_request_webhooks 已移除。

请求头:

plaintext
X-Gitlab-Event: Member Hook

负载示例:

json
1{ 2 "created_at": "2020-12-11T04:57:22Z", 3 "updated_at": "2020-12-12T08:52:34Z", 4 "group_name": "webhook-test", 5 "group_path": "webhook-test", 6 "group_id": 100, 7 "user_username": "test_user", 8 "user_name": "Test User", 9 "user_email": "testuser@webhooktest.com", 10 "user_id": 64, 11 "group_access": "Guest", 12 "group_plan": null, 13 "expires_at": "2020-12-14T00:00:00Z", 14 "event_name": "user_access_request_denied_for_group" 15}

项目事件#

Tier: 专业版,旗舰版

版本历史
  • 在极狐GitLab 17.6 中引入

这些事件仅针对群组 webhook 触发。

项目事件在以下情况触发:

在群组中创建项目#

请求头:

plaintext
X-Gitlab-Event: Project Hook

负载示例:

json
1{ 2 "event_name": "project_create", 3 "created_at": "2024-10-07T10:43:48Z", 4 "updated_at": "2024-10-07T10:43:48Z", 5 "name": "project1", 6 "path": "project1", 7 "path_with_namespace": "group1/project1", 8 "project_id": 22, 9 "project_namespace_id": 32, 10 "owners": [{ 11 "name": "John", 12 "email": "user1@example.com" 13 }], 14 "project_visibility": "private" 15}

在群组中删除项目#

请求头:

plaintext
X-Gitlab-Event: Project Hook

负载示例:

json
1{ 2 "event_name": "project_destroy", 3 "created_at": "2024-10-07T10:43:48Z", 4 "updated_at": "2024-10-07T10:43:48Z", 5 "name": "project1", 6 "path": "project1", 7 "path_with_namespace": "group1/project1", 8 "project_id": 22, 9 "project_namespace_id": 32, 10 "owners": [{ 11 "name": "John", 12 "email": "user1@example.com" 13 }], 14 "project_visibility": "private" 15}

子群组事件#

Tier: 专业版,旗舰版

这些事件仅针对群组 webhook 触发。

子群组事件在以下情况触发:

在群组中创建子群组#

请求头:

plaintext
X-Gitlab-Event: Subgroup Hook

负载示例:

json
1{ 2 3 "created_at": "2021-01-20T09:40:12Z", 4 "updated_at": "2021-01-20T09:40:12Z", 5 "event_name": "subgroup_create", 6 "name": "subgroup1", 7 "path": "subgroup1", 8 "full_path": "group1/subgroup1", 9 "group_id": 10, 10 "parent_group_id": 7, 11 "parent_name": "group1", 12 "parent_path": "group1", 13 "parent_full_path": "group1" 14 15}

从群组中移除子群组#

子群组被转移到新的父群组时,不会触发此 webhook。

请求头:

plaintext
X-Gitlab-Event: Subgroup Hook

负载示例:

json
1{ 2 3 "created_at": "2021-01-20T09:40:12Z", 4 "updated_at": "2021-01-20T09:40:12Z", 5 "event_name": "subgroup_destroy", 6 "name": "subgroup1", 7 "path": "subgroup1", 8 "full_path": "group1/subgroup1", 9 "group_id": 10, 10 "parent_group_id": 7, 11 "parent_name": "group1", 12 "parent_path": "group1", 13 "parent_full_path": "group1" 14 15}

功能标志事件#

当功能标志开启或关闭时,会触发功能标志事件。

请求头:

plaintext
X-Gitlab-Event: Feature Flag Hook

负载示例:

json
1{ 2 "object_kind": "feature_flag", 3 "project": { 4 "id": 1, 5 "name":"Gitlab Test", 6 "description":"Aut reprehenderit ut est.", 7 "web_url":"http://example.com/gitlabhq/gitlab-test", 8 "avatar_url":null, 9 "git_ssh_url":"git@example.com:gitlabhq/gitlab-test.git", 10 "git_http_url":"http://example.com/gitlabhq/gitlab-test.git", 11 "namespace":"GitlabHQ", 12 "visibility_level":20, 13 "path_with_namespace":"gitlabhq/gitlab-test", 14 "default_branch":"master", 15 "ci_config_path": null, 16 "homepage":"http://example.com/gitlabhq/gitlab-test", 17 "url":"http://example.com/gitlabhq/gitlab-test.git", 18 "ssh_url":"git@example.com:gitlabhq/gitlab-test.git", 19 "http_url":"http://example.com/gitlabhq/gitlab-test.git" 20 }, 21 "user": { 22 "id": 1, 23 "name": "Administrator", 24 "username": "root", 25 "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", 26 "email": "admin@example.com" 27 }, 28 "user_url": "http://example.com/root", 29 "object_attributes": { 30 "id": 6, 31 "name": "test-feature-flag", 32 "description": "test-feature-flag-description", 33 "active": true 34 } 35}

发布事件#

版本历史
  • 删除发布事件在极狐GitLab 16.5 中引入

当发布被创建、更新或删除时,会触发发布事件。

负载中 object_attributes.action 的可用值包括:

  • create
  • update
  • delete

请求头:

plaintext
X-Gitlab-Event: Release Hook

负载示例:

json
1{ 2 "id": 1, 3 "created_at": "2020-11-02 12:55:12 UTC", 4 "description": "v1.1 has been released", 5 "name": "v1.1", 6 "released_at": "2020-11-02 12:55:12 UTC", 7 "tag": "v1.1", 8 "object_kind": "release", 9 "project": { 10 "id": 2, 11 "name": "release-webhook-example", 12 "description": "", 13 "web_url": "https://example.com/gitlab-org/release-webhook-example", 14 "avatar_url": null, 15 "git_ssh_url": "ssh://git@example.com/gitlab-org/release-webhook-example.git", 16 "git_http_url": "https://example.com/gitlab-org/release-webhook-example.git", 17 "namespace": "Gitlab", 18 "visibility_level": 0, 19 "path_with_namespace": "gitlab-org/release-webhook-example", 20 "default_branch": "master", 21 "ci_config_path": null, 22 "homepage": "https://example.com/gitlab-org/release-webhook-example", 23 "url": "ssh://git@example.com/gitlab-org/release-webhook-example.git", 24 "ssh_url": "ssh://git@example.com/gitlab-org/release-webhook-example.git", 25 "http_url": "https://example.com/gitlab-org/release-webhook-example.git" 26 }, 27 "url": "https://example.com/gitlab-org/release-webhook-example/-/releases/v1.1", 28 "action": "create", 29 "assets": { 30 "count": 5, 31 "links": [ 32 { 33 "id": 1, 34 "link_type": "other", 35 "name": "Changelog", 36 "url": "https://example.net/changelog" 37 } 38 ], 39 "sources": [ 40 { 41 "format": "zip", 42 "url": "https://example.com/gitlab-org/release-webhook-example/-/archive/v1.1/release-webhook-example-v1.1.zip" 43 }, 44 { 45 "format": "tar.gz", 46 "url": "https://example.com/gitlab-org/release-webhook-example/-/archive/v1.1/release-webhook-example-v1.1.tar.gz" 47 }, 48 { 49 "format": "tar.bz2", 50 "url": "https://example.com/gitlab-org/release-webhook-example/-/archive/v1.1/release-webhook-example-v1.1.tar.bz2" 51 }, 52 { 53 "format": "tar", 54 "url": "https://example.com/gitlab-org/release-webhook-example/-/archive/v1.1/release-webhook-example-v1.1.tar" 55 } 56 ] 57 }, 58 "commit": { 59 "id": "ee0a3fb31ac16e11b9dbb596ad16d4af654d08f8", 60 "message": "Release v1.1", 61 "title": "Release v1.1", 62 "timestamp": "2020-10-31T14:58:32+11:00", 63 "url": "https://example.com/gitlab-org/release-webhook-example/-/commit/ee0a3fb31ac16e11b9dbb596ad16d4af654d08f8", 64 "author": { 65 "name": "Example User", 66 "email": "user@example.com" 67 } 68 } 69}

里程碑事件#

版本历史
  • 在极狐GitLab 18.2 中引入

当里程碑被创建、关闭、重新打开或删除时,会触发里程碑事件。

负载中 object_attributes.action 的可用值包括:

  • create
  • close
  • reopen

请求头:

plaintext
X-Gitlab-Event: Milestone Hook

负载示例:

json
1{ 2 "object_kind": "milestone", 3 "event_type": "milestone", 4 "project": { 5 "id": 1, 6 "name": "Gitlab Test", 7 "description": "Aut reprehenderit ut est.", 8 "web_url": "http://example.com/gitlabhq/gitlab-test", 9 "avatar_url": null, 10 "git_ssh_url": "git@example.com:gitlabhq/gitlab-test.git", 11 "git_http_url": "http://example.com/gitlabhq/gitlab-test.git", 12 "namespace": "GitlabHQ", 13 "visibility_level": 20, 14 "path_with_namespace": "gitlabhq/gitlab-test", 15 "default_branch": "master", 16 "ci_config_path": null, 17 "homepage": "http://example.com/gitlabhq/gitlab-test", 18 "url": "http://example.com/gitlabhq/gitlab-test.git", 19 "ssh_url": "git@example.com:gitlabhq/gitlab-test.git", 20 "http_url": "http://example.com/gitlabhq/gitlab-test.git" 21 }, 22 "object_attributes": { 23 "id": 61, 24 "iid": 10, 25 "title": "v1.0", 26 "description": "First stable release", 27 "state": "active", 28 "created_at": "2025-06-16 14:10:57 UTC", 29 "updated_at": "2025-06-16 14:10:57 UTC", 30 "due_date": "2025-06-30", 31 "start_date": "2025-06-16", 32 "group_id": null, 33 "project_id": 1 34 }, 35 "action": "create" 36}

表情事件#

版本历史

当在以下对象上添加或移除表情反应时,会触发表情事件:

  • 议题
  • 合并请求
  • 项目代码片段
  • 以下是其评论:
    • 议题
    • 合并请求
    • 项目代码片段
    • 提交

负载中 object_attributes.action 的可用值包括:

  • award 表示添加反应
  • revoke 表示移除反应

请求头:

plaintext
X-Gitlab-Event: Emoji Hook

负载示例:

json
1{ 2 "object_kind": "emoji", 3 "event_type": "award", 4 "user": { 5 "id": 1, 6 "name": "Blake Bergstrom", 7 "username": "root", 8 "avatar_url": "http://example.com/uploads/-/system/user/avatar/1/avatar.png", 9 "email": "[REDACTED]" 10 }, 11 "project_id": 6, 12 "project": { 13 "id": 6, 14 "name": "Flight", 15 "description": "Velit fugit aperiam illum deleniti odio sequi.", 16 "web_url": "http://example.com/flightjs/Flight", 17 "avatar_url": null, 18 "git_ssh_url": "ssh://git@example.com/flightjs/Flight.git", 19 "git_http_url": "http://example.com/flightjs/Flight.git", 20 "namespace": "Flightjs", 21 "visibility_level": 20, 22 "path_with_namespace": "flightjs/Flight", 23 "default_branch": "master", 24 "ci_config_path": null, 25 "homepage": "http://example.com/flightjs/Flight", 26 "url": "ssh://git@example.com/flightjs/Flight.git", 27 "ssh_url": "ssh://git@example.com/flightjs/Flight.git", 28 "http_url": "http://example.com/flightjs/Flight.git" 29 }, 30 "object_attributes": { 31 "user_id": 1, 32 "created_at": "2023-07-04 20:44:11 UTC", 33 "id": 1, 34 "name": "thumbsup", 35 "awardable_type": "Note", 36 "awardable_id": 363, 37 "updated_at": "2023-07-04 20:44:11 UTC", 38 "action": "award", 39 "awarded_on_url": "http://example.com/flightjs/Flight/-/issues/42#note_363" 40 }, 41 "note": { 42 "attachment": null, 43 "author_id": 1, 44 "change_position": null, 45 "commit_id": null, 46 "created_at": "2023-07-04 15:09:55 UTC", 47 "discussion_id": "c3d97fd471f210a5dc8b97a409e3bea95ee06c14", 48 "id": 363, 49 "line_code": null, 50 "note": "Testing 123", 51 "noteable_id": 635, 52 "noteable_type": "Issue", 53 "original_position": null, 54 "position": null, 55 "project_id": 6, 56 "resolved_at": null, 57 "resolved_by_id": null, 58 "resolved_by_push": null, 59 "st_diff": null, 60 "system": false, 61 "type": null, 62 "updated_at": "2023-07-04 19:58:46 UTC", 63 "updated_by_id": null, 64 "description": "Testing 123", 65 "url": "http://example.com/flightjs/Flight/-/issues/42#note_363" 66 }, 67 "issue": { 68 "author_id": 1, 69 "closed_at": null, 70 "confidential": false, 71 "created_at": "2023-07-04 14:59:43 UTC", 72 "description": "Issue description!", 73 "discussion_locked": null, 74 "due_date": null, 75 "id": 635, 76 "iid": 42, 77 "last_edited_at": null, 78 "last_edited_by_id": null, 79 "milestone_id": null, 80 "moved_to_id": null, 81 "duplicated_to_id": null, 82 "project_id": 6, 83 "relative_position": 18981, 84 "state_id": 1, 85 "time_estimate": 0, 86 "title": "New issue!", 87 "updated_at": "2023-07-04 15:09:55 UTC", 88 "updated_by_id": null, 89 "weight": null, 90 "health_status": null, 91 "url": "http://example.com/flightjs/Flight/-/issues/42", 92 "total_time_spent": 0, 93 "time_change": 0, 94 "human_total_time_spent": null, 95 "human_time_change": null, 96 "human_time_estimate": null, 97 "assignee_ids": [ 98 1 99 ], 100 "assignee_id": 1, 101 "labels": [ 102 103 ], 104 "state": "opened", 105 "severity": "unknown" 106 } 107}

项目和群组访问令牌事件#

版本历史

访问令牌到期事件会在访问令牌到期前触发。 这些事件会触发:

  • 令牌到期前 7 天
  • 令牌到期前 30 天(需要配置)
  • 令牌到期前 60 天(需要配置)

有关配置 30 天和 60 天通知的信息,请参见:

负载中 event_name 的可用值包括:

  • expiring_access_token

请求头:

plaintext
X-Gitlab-Event: Resource Access Token Hook

项目负载示例:

json
1{ 2 "object_kind": "access_token", 3 "project": { 4 "id": 7, 5 "name": "Flight", 6 "description": "Eum dolore maxime atque reprehenderit voluptatem.", 7 "web_url": "https://example.com/flightjs/Flight", 8 "avatar_url": null, 9 "git_ssh_url": "ssh://git@example.com/flightjs/Flight.git", 10 "git_http_url": "https://example.com/flightjs/Flight.git", 11 "namespace": "Flightjs", 12 "visibility_level": 0, 13 "path_with_namespace": "flightjs/Flight", 14 "default_branch": "master", 15 "ci_config_path": null, 16 "homepage": "https://example.com/flightjs/Flight", 17 "url": "ssh://git@example.com/flightjs/Flight.git", 18 "ssh_url": "ssh://git@example.com/flightjs/Flight.git", 19 "http_url": "https://example.com/flightjs/Flight.git" 20 }, 21 "object_attributes": { 22 "user_id": 90, 23 "created_at": "2024-01-24 16:27:40 UTC", 24 "id": 25, 25 "name": "acd", 26 "expires_at": "2024-01-26", 27 "last_used_at": "2024-01-20 10:15:30 UTC" 28 }, 29 "event_name": "expiring_access_token" 30}

群组负载示例:

json
1{ 2 "object_kind": "access_token", 3 "group": { 4 "group_name": "Twitter", 5 "group_path": "twitter", 6 "group_id": 35, 7 "full_path": "twitter" 8 }, 9 "object_attributes": { 10 "user_id": 90, 11 "created_at": "2024-01-24 16:27:40 UTC", 12 "id": 25, 13 "name": "acd", 14 "expires_at": "2024-01-26", 15 "last_used_at": "2024-01-20 10:15:30 UTC" 16 }, 17 "event_name": "expiring_access_token" 18}

项目和群组部署令牌事件#

版本历史
  • 在极狐GitLab 18.4 中引入,当时以一个功能标志启用,命名为 project_deploy_token_expiring_notifications。默认禁用。

部署令牌到期事件会在部署令牌到期前触发。 这些事件会触发:

  • 令牌到期前 7 天。
  • 令牌到期前 30 天。
  • 令牌到期前 60 天。

负载中 event_name 的可用值包括:

  • expiring_deploy_token

请求头:

plaintext
X-Gitlab-Event: Resource Deploy Token Hook

项目负载示例:

json
1{ 2 "object_kind": "deploy_token", 3 "project": { 4 "id": 2, 5 "name": "Gitlab Test", 6 "description": "Voluptates sit architecto quos distinctio.", 7 "web_url": "https://gitlab.example.com/gitlab-org/gitlab-test", 8 "avatar_url": null, 9 "git_ssh_url": "ssh://git@gitlab.example.com:2222/gitlab-org/gitlab-test.git", 10 "git_http_url": "https://gitlab.example.com/gitlab-org/gitlab-test.git", 11 "namespace": "Gitlab Org", 12 "visibility_level": 10, 13 "path_with_namespace": "gitlab-org/gitlab-test", 14 "default_branch": "master", 15 "ci_config_path": null, 16 "homepage": "https://gitlab.example.com/gitlab-org/gitlab-test", 17 "url": "ssh://git@gitlab.example.com:2222/gitlab-org/gitlab-test.git", 18 "ssh_url": "ssh://git@gitlab.example.com:2222/gitlab-org/gitlab-test.git", 19 "http_url": "https://gitlab.example.com/gitlab-org/gitlab-test.git" 20 }, 21 "object_attributes": { 22 "id": 79, 23 "name": "seven-days-6days", 24 "expires_at": "2025-08-03 07:57:25 UTC", 25 "created_at": "2025-07-28 07:57:25 UTC", 26 "revoked": false, 27 "deploy_token_type": "project_type" 28 }, 29 "event_name": "expiring_deploy_token" 30}

漏洞事件#

版本历史
  • 在极狐GitLab 17.7 中引入,当时以一个功能标志启用,命名为 vulnerabilities_as_webhook_events。默认禁用。
  • 在极狐GitLab 17.8 中引入:在创建漏洞或议题与漏洞关联时创建事件的功能。
  • 在极狐GitLab 17.11 中全面可用。功能标志 vulnerabilities_as_webhook_events 已移除。

在以下情况会触发漏洞事件:

请求头:

plaintext
X-Gitlab-Event: Vulnerability Hook

负载示例:

json
1{ 2 "object_kind": "vulnerability", 3 "object_attributes": { 4 "url": "https://example.com/flightjs/Flight/-/security/vulnerabilities/1", 5 "title": "REXML DoS vulnerability", 6 "state": "confirmed", 7 "project_id": 50, 8 "location": { 9 "file": "Gemfile.lock", 10 "dependency": { 11 "package": { 12 "name": "rexml" 13 }, 14 "version": "3.3.1" 15 } 16 }, 17 "cvss": [ 18 { 19 "vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", 20 "vendor": "NVD" 21 } 22 ], 23 "severity": "high", 24 "severity_overridden": false, 25 "identifiers": [ 26 { 27 "name": "Gemnasium-29dce398-220a-4315-8c84-16cd8b6d9b05", 28 "external_id": "29dce398-220a-4315-8c84-16cd8b6d9b05", 29 "external_type": "gemnasium", 30 "url": "https://gitlab.com/gitlab-org/security-products/gemnasium-db/-/blob/master/gem/rexml/CVE-2024-41123.yml" 31 }, 32 { 33 "name": "CVE-2024-41123", 34 "external_id": "CVE-2024-41123", 35 "external_type": "cve", 36 "url": "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-41123" 37 } 38 ], 39 "issues": [ 40 { 41 "title": "REXML ReDoS vulnerability", 42 "url": "https://example.com/flightjs/Flight/-/issues/1", 43 "created_at": "2025-01-08T00:46:14.429Z", 44 "updated_at": "2025-01-08T00:46:14.429Z" 45 } 46 ], 47 "report_type": "dependency_scanning", 48 "scanner_external_id": "gitlab-sbom-vulnerability-scanner", 49 "confidence": "unknown", 50 "confidence_overridden": false, 51 "confirmed_at": "2025-01-08T00:46:14.413Z", 52 "confirmed_by_id": 1, 53 "dismissed_at": null, 54 "dismissed_by_id": null, 55 "resolved_at": null, 56 "resolved_by_id": null, 57 "auto_resolved": false, 58 "resolved_on_default_branch": false, 59 "created_at": "2025-01-08T00:46:14.413Z", 60 "updated_at": "2025-01-08T00:46:14.413Z" 61 } 62}