人则

注意:从GitLab 8.5开始:

  • 存储库键已弃用,而使用项目关键
  • project.ssh_url键已弃用,而使用project.git_ssh_url关键
  • project.http_url键已弃用,而使用project.git_http_url关键

项目webhooks允许你在新代码被推送或新问题被创建时触发URL。你可以配置webhook来监听特定的事件,比如推送、问题或合并请求。GitLab将向webhook URL发送一个带有数据的POST请求。

webhook可用于更新外部问题跟踪器、触发CI作业、更新备份镜像,甚至部署到生产服务器。

通过转到项目的webhooks页面来导航到该页面设置cx110集成

Webhook端点提示

如果你正在编写自己的端点(web服务器),将接收GitLab webhook,请记住以下事情:

  • 您的端点应该尽可能快地发送HTTP响应。如果等待时间太长,GitLab可能会认为钩子失败并重试它。
  • 你的端点应该总是返回一个有效的HTTP响应。如果你不这样做,那么GitLab将认为钩子失败并重试它。大多数HTTP库都会自动为您处理这个问题,但如果您正在编写低级钩子,请务必记住这一点。
  • GitLab忽略端点返回的HTTP状态码。

秘密令牌

如果您指定了一个秘密令牌,它将与钩子请求一起发送X-Gitlab-TokenHTTP报头。你的webhook端点可以检查请求是否合法。

SSL验证

默认情况下,webhook端点的SSL证书是基于证书颁发机构的内部列表进行验证的,这意味着证书不能自签名。

你可以在你的GitLab项目的webhook设置中关闭它。

SSL验证”class=

事件

下面描述了支持的事件。

推动事件

在推送到存储库时触发,但推送标签时除外。

注意:当一次推送超过20个提交时提交由于性能原因,Web hook属性将只包含前20个。加载详细的提交数据非常昂贵。注意,尽管只有20个提交存在于提交属性,total_commits_count属性将包含实际总数。

请求头

X-Gitlab-Event: Push Hook

请求主体:

“object_kind”“推”“之前”“95790 bf891e76fee5e1747ab589903a6a1f80f22”“后”“da1560886d4f094c3e6c9ef40349f7d38b5d27d7”“ref”“refs /头/大师”“checkout_sha”“da1560886d4f094c3e6c9ef40349f7d38b5d27d7”“user_id”4“user_name”“约翰·史密斯”“user_username”“又”“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“项目”: {“id”15“名称”“散居”“描述””““web_url”“http://example.com/mike/diaspora”“avatar_url”“git_ssh_url”“git@example.com:迈克/ diaspora.git”“git_http_url”“http://example.com/mike/diaspora.git”“名称”“迈克”“visibility_level”0“path_with_namespace”“迈克/移民”“default_branch”“主”“主页”“http://example.com/mike/diaspora”“url”“git@example.com:迈克/ diaspora.git”“ssh_url”“git@example.com:迈克/ diaspora.git”“http_url”“http://example.com/mike/diaspora.git”},“库”: {“名称”“散居”“url”“git@example.com:迈克/ diaspora.git”“描述””““主页”“http://example.com/mike/diaspora”“git_http_url”“http://example.com/mike/diaspora.git”“git_ssh_url”“git@example.com:迈克/ diaspora.git”“visibility_level”0},“提交”(“id”“b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327”“消息”“更新加泰罗尼亚语翻译为e38cb41。”“时间戳”“2011 - 12 - 12 - t14:27:31 + 02:00”“url”“http://example.com/mike/diaspora/commit/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327”“作者”“名称”“乔迪Mallach”“电子邮件”“jordi@softcatala.org”},“添加”(“变更”],“修改”(“应用程序/控制器/ application.rb”],“删除”[]},“id”“da1560886d4f094c3e6c9ef40349f7d38b5d27d7”“消息”“固定readme”“时间戳”“2012 - 01 - 03 - t23:36:29 + 02:00”“url”“http://example.com/mike/diaspora/commit/da1560886d4f094c3e6c9ef40349f7d38b5d27d7”“作者”“名称”“GitLab开发用户”“电子邮件”“gitlabdev@dv6700(没有)”。},“添加”(“变更”],“修改”(“应用程序/控制器/ application.rb”],“删除”[]}],“total_commits_count”4}

标签的事件

在向存储库创建(或删除)标记时触发。

请求头

X-Gitlab-Event:标签推送钩子

请求主体:

“object_kind”“tag_push”“之前”“0000000000000000000000000000000000000000”“后”“82 b3d5ae55f7080f1e6022629cdb57bfae7cccc7”“ref”“refs /标签/ v1.0.0”“checkout_sha”“82 b3d5ae55f7080f1e6022629cdb57bfae7cccc7”“user_id”1“user_name”“约翰·史密斯”“user_avatar”“https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8: / / s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6 ? s = 80”“project_id”1“项目”: {“id”1“名称”“例子”“描述””““web_url”“http://example.com/jsmith/example”“avatar_url”“git_ssh_url”“git@example.com: jsmith / example.git”“git_http_url”“http://example.com/jsmith/example.git”“名称”“又”“visibility_level”0“path_with_namespace”“jsmith /例子”“default_branch”“主”“主页”“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”},“库”: {“名称”“例子”“url”“ssh: / / git@example.com/jsmith/example.git”“描述””““主页”“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},“提交”[],“total_commits_count”0}

问题事件

当创建新问题或更新/关闭/重新打开现有问题时触发。

请求头

X-Gitlab-Event: Issue钩子

请求主体:

“object_kind”“问题”“用户”“名称”“管理员”“用户名”“根”“avatar_url”“http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\ u0026 d = identicon”},“项目”“id”1“名称”“Gitlab测试”“描述”“我很抱歉。”“web_url”“http://example.com/gitlabhq/gitlab-test”“avatar_url”“git_ssh_url”“git@example.com: gitlabhq / gitlab-test.git”“git_http_url”“http://example.com/gitlabhq/gitlab-test.git”“名称”“GitlabHQ”“visibility_level”20.“path_with_namespace”“gitlabhq / gitlab-test”“default_branch”“主”“主页”“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”},“库”“名称”“Gitlab测试”“url”“http://example.com/gitlabhq/gitlab-test.git”“描述”“我很抱歉。”“主页”“http://example.com/gitlabhq/gitlab-test”},“object_attributes”“id”301“标题”"新的API:创建/更新/删除文件"“assignee_ids”(51],“assignee_id”51“author_id”51“project_id”14“created_at”“2013 - 12 - 03 - t17:15:43z”“updated_at”“2013 - 12 - 03 - t17:15:43z”“位置”0“branch_name”“描述”“为存储库操作创建新的API”“milestone_id”“状态”“打开”“iid”23“url”“http://example.com/diaspora/issues/23”“行动”“开放”},“因此”[{“名称”“User1”“用户名”“user1”“avatar_url”“http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\ u0026 d = identicon”}),“受让人”“名称”“User1”“用户名”“user1”“avatar_url”“http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\ u0026 d = identicon”},“标签”[{“id”206“标题”“API”“颜色”“# ffffff”“project_id”14“created_at”“2013 - 12 - 03 - t17:15:43z”“updated_at”“2013 - 12 - 03 - t17:15:43z”“模板”“描述”“与空气污染指数有关的事宜”“类型”“ProjectLabel”“group_id”41}),“改变”“updated_by_id”(1],“updated_at”("2017-09-15 16:50:55 utc "2017-09-15 16:52:00 utc],“标签”“以前”[{“id”206“标题”“API”“颜色”“# ffffff”“project_id”14“created_at”“2013 - 12 - 03 - t17:15:43z”“updated_at”“2013 - 12 - 03 - t17:15:43z”“模板”“描述”“与空气污染指数有关的事宜”“类型”“ProjectLabel”“group_id”41}),“当前”[{“id”205“标题”“平台”“颜色”“123123 #”“project_id”14“created_at”“2013 - 12 - 03 - t17:15:43z”“updated_at”“2013 - 12 - 03 - t17:15:43z”“模板”“描述”“平台相关问题”“类型”“ProjectLabel”“group_id”41})}}}

请注意受让人assignee_id键已弃用,现在只显示第一个受让人。

评论事件

当对提交、合并请求、问题和代码片段做出新的注释时触发。注释数据将存储在object_attributes(如。请注意noteable_type).有效负载还将包括关于评论目标的信息。例如,对某一问题的评论将包括特定的问题信息问题关键。有效的目标类型:

  1. 提交
  2. merge_request
  3. 问题
  4. 片段

提交注释

请求头

X-Gitlab-Event: Note Hook

请求主体:

“object_kind”“注意”“用户”“名称”“管理员”“用户名”“根”“avatar_url”“http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\ u0026 d = identicon”},“project_id”5“项目”: {“id”5“名称”“Gitlab测试”“描述”“我很抱歉。”“web_url”“http://example.com/gitlabhq/gitlab-test”“avatar_url”“git_ssh_url”“git@example.com: gitlabhq / gitlab-test.git”“git_http_url”“http://example.com/gitlabhq/gitlab-test.git”“名称”“GitlabHQ”“visibility_level”20.“path_with_namespace”“gitlabhq / gitlab-test”“default_branch”“主”“主页”“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”},“库”: {“名称”“Gitlab测试”“url”“http://example.com/gitlab-org/gitlab-test.git”“描述”“我很抱歉。”“主页”“http://example.com/gitlab-org/gitlab-test”},“object_attributes”“id”1243“注意”“这是一个提交评论。这是怎么回事?”“noteable_type”“提交”“author_id”1“created_at”"2015-05-17 18:08:09 utc "“updated_at”"2015-05-17 18:08:09 utc "“project_id”5“附件”“line_code”“bec9703f7a456cd2b4ab5fb3220ae016e3e394e3_0_1”“commit_id”“cfe32cf61b73a0d5e9f13e774abde7ff789b1660”“noteable_id”“系统”“st_diff”" diff "”——/ dev / null\ n+ + + b / 6\ n@@ -0,0 +1 @@\ n+子项目提交409f37c4f05865e4fb208c771485f211a22c4c2d\ n“new_path”“6”“old_path”“6”“a_mode”“0”“b_mode”“160000”“new_file”真正的“renamed_file”“deleted_file”},“url”“http://example.com/gitlab-org/gitlab-test/commit/cfe32cf61b73a0d5e9f13e774abde7ff789b1660 # note_1243”},“提交”“id”“cfe32cf61b73a0d5e9f13e774abde7ff789b1660”“消息”“添加子模块\ n \ n署名:德米特里·扎波罗热茨\ u003 cdmitriy.zaporozhets@gmail.com\ u003 e\ n“时间戳”“2014 - 02 - 27 - t10:06:20 + 02:00”“url”“http://example.com/gitlab-org/gitlab-test/commit/cfe32cf61b73a0d5e9f13e774abde7ff789b1660”“作者”“名称”“他在Zaporozhets”“电子邮件”“dmitriy.zaporozhets@gmail.com”}}}

对合并请求的注释

请求头

X-Gitlab-Event: Note Hook

请求主体:

“object_kind”“注意”“用户”“名称”“管理员”“用户名”“根”“avatar_url”“http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\ u0026 d = identicon”},“project_id”5“项目”: {“id”5“名称”“Gitlab测试”“描述”“我很抱歉。”“web_url”“http://example.com/gitlab-org/gitlab-test”“avatar_url”“git_ssh_url”“git@example.com: gitlab-org gitlab-test.git”“git_http_url”“http://example.com/gitlab-org/gitlab-test.git”“名称”“Gitlab Org”“visibility_level”10“path_with_namespace”“gitlab-org gitlab-test”“default_branch”“主”“主页”“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”},“库”: {“名称”“Gitlab测试”“url”“http://localhost/gitlab-org/gitlab-test.git”“描述”“我很抱歉。”“主页”“http://example.com/gitlab-org/gitlab-test”},“object_attributes”“id”1244“注意”“这个MR需要改进。”“noteable_type”“MergeRequest”“author_id”1“created_at”"2015-05-17 18:21:36 "“updated_at”"2015-05-17 18:21:36 "“project_id”5“附件”“line_code”“commit_id””““noteable_id”7“系统”“st_diff”“url”“http://example.com/gitlab-org/gitlab-test/merge_requests/1 # note_1244”},“merge_request”“id”7“target_branch”“减价”“source_branch”“主”“source_project_id”5“author_id”8“assignee_id”28“标题”“时间和债务是一样的。”“created_at”"2015-03-01 20:12:53 utc "“updated_at”"2015-03-21 18:27:27 utc "“milestone_id”11“状态”“打开”“merge_status”“cannot_be_merged”“target_project_id”5“iid”1“描述”“让我们暂时假设腐败。”建筑与动物活动的结合。“Vitae numquam volupate est nature”“位置”0“源”: {“名称”“Gitlab测试”“描述”“我很抱歉。”“web_url”“http://example.com/gitlab-org/gitlab-test”“avatar_url”“git_ssh_url”“git@example.com: gitlab-org gitlab-test.git”“git_http_url”“http://example.com/gitlab-org/gitlab-test.git”“名称”“Gitlab Org”“visibility_level”10“path_with_namespace”“gitlab-org gitlab-test”“default_branch”“主”“主页”“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”},“目标”“名称”“Gitlab测试”“描述”“我很抱歉。”“web_url”“http://example.com/gitlab-org/gitlab-test”“avatar_url”“git_ssh_url”“git@example.com: gitlab-org gitlab-test.git”“git_http_url”“http://example.com/gitlab-org/gitlab-test.git”“名称”“Gitlab Org”“visibility_level”10“path_with_namespace”“gitlab-org gitlab-test”“default_branch”“主”“主页”“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”“562 e173be03b8ff2efb05345d12df18815438a4b”“消息”"将分支'another-branch'合并到'master'中"\ n \ n检查这个测试\ n“时间戳”2015 - 04 - 08 - t21: 00:25-07:00”“url”“http://example.com/gitlab-org/gitlab-test/commit/562e173be03b8ff2efb05345d12df18815438a4b”“作者”“名称”“约翰·史密斯”“电子邮件”“john@example.com”}},“work_in_progress”“受让人”“名称”“User1”“用户名”“user1”“avatar_url”“http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\ u0026 d = identicon”}}}

对问题的评论

请求头

X-Gitlab-Event: Note Hook

请求主体:

“object_kind”“注意”“用户”“名称”“管理员”“用户名”“根”“avatar_url”“http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\ u0026 d = identicon”},“project_id”5“项目”: {“id”5“名称”“Gitlab测试”“描述”“我很抱歉。”“web_url”“http://example.com/gitlab-org/gitlab-test”“avatar_url”“git_ssh_url”“git@example.com: gitlab-org gitlab-test.git”“git_http_url”“http://example.com/gitlab-org/gitlab-test.git”“名称”“Gitlab Org”“visibility_level”10“path_with_namespace”“gitlab-org gitlab-test”“default_branch”“主”“主页”“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”},“库”: {“名称”“散居”“url”“git@example.com:迈克/ diaspora.git”“描述””““主页”“http://example.com/mike/diaspora”},“object_attributes”“id”1241“注意”“Hello world”“noteable_type”“问题”“author_id”1“created_at”2015-05-17 17:06:40 utc“updated_at”2015-05-17 17:06:40 utc“project_id”5“附件”“line_code”“commit_id””““noteable_id”92“系统”“st_diff”“url”“http://example.com/gitlab-org/gitlab-test/issues/17 # note_1241”},“问题”“id”92“标题”“测试”“assignee_ids”[],“assignee_id”“author_id”1“project_id”5“created_at”"2015-04-12 14:53:17 utc "“updated_at”"2015-04-26 08:28:42 utc "“位置”0“branch_name”“描述”“测试”“milestone_id”“状态”“关闭”“iid”17}}

请注意assignee_id字段已弃用,现在只显示第一个受让人。

对代码段的注释

请求头

X-Gitlab-Event: Note Hook

请求主体:

“object_kind”“注意”“用户”“名称”“管理员”“用户名”“根”“avatar_url”“http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\ u0026 d = identicon”},“project_id”5“项目”: {“id”5“名称”“Gitlab测试”“描述”“我很抱歉。”“web_url”“http://example.com/gitlab-org/gitlab-test”“avatar_url”“git_ssh_url”“git@example.com: gitlab-org gitlab-test.git”“git_http_url”“http://example.com/gitlab-org/gitlab-test.git”“名称”“Gitlab Org”“visibility_level”10“path_with_namespace”“gitlab-org gitlab-test”“default_branch”“主”“主页”“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”},“库”: {“名称”“Gitlab测试”“url”“http://example.com/gitlab-org/gitlab-test.git”“描述”“我很抱歉。”“主页”“http://example.com/gitlab-org/gitlab-test”},“object_attributes”“id”1245“注意”“这段代码在做它应该做的事情吗?”“noteable_type”“片段”“author_id”1“created_at”2015-05-17 18:35:50 utc“updated_at”2015-05-17 18:35:50 utc“project_id”5“附件”“line_code”“commit_id””““noteable_id”53“系统”“st_diff”“url”“http://example.com/gitlab-org/gitlab-test/snippets/53 # note_1245”},“片段”“id”53“标题”“测试”“内容”"显示'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”“类型”“ProjectSnippet”“visibility_level”0}}

合并请求事件

当创建新的合并请求、更新/合并/关闭现有合并请求或在源分支中添加提交时触发。

请求头

X-Gitlab-Event:合并请求钩子

请求主体:

“object_kind”“merge_request”“用户”“名称”“管理员”“用户名”“根”“avatar_url”“http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\ u0026 d = identicon”},“项目”“id”1“名称”“Gitlab测试”“描述”“我很抱歉。”“web_url”“http://example.com/gitlabhq/gitlab-test”“avatar_url”“git_ssh_url”“git@example.com: gitlabhq / gitlab-test.git”“git_http_url”“http://example.com/gitlabhq/gitlab-test.git”“名称”“GitlabHQ”“visibility_level”20.“path_with_namespace”“gitlabhq / gitlab-test”“default_branch”“主”“主页”“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”},“库”“名称”“Gitlab测试”“url”“http://example.com/gitlabhq/gitlab-test.git”“描述”“我很抱歉。”“主页”“http://example.com/gitlabhq/gitlab-test”},“object_attributes”“id”99“target_branch”“主”“source_branch”“ms-viewport”“source_project_id”14“author_id”51“assignee_id”6“标题”“MS-Viewport”“created_at”“2013 - 12 - 03 - t17:23:34z”“updated_at”“2013 - 12 - 03 - t17:23:34z”“milestone_id”“状态”“打开”“merge_status”“不”“target_project_id”14“iid”1“描述””““源”“名称”“了不起的项目”“描述”“我很抱歉。”“web_url”“http://example.com/awesome_space/awesome_project”“avatar_url”“git_ssh_url”“git@example.com: awesome_space / awesome_project.git”“git_http_url”“http://example.com/awesome_space/awesome_project.git”“名称”“可怕的空间”“visibility_level”20.“path_with_namespace”“awesome_space / awesome_project”“default_branch”“主”“主页”“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”},“目标”“名称”“了不起的项目”“描述”“我很抱歉。”“web_url”“http://example.com/awesome_space/awesome_project”“avatar_url”“git_ssh_url”“git@example.com: awesome_space / awesome_project.git”“git_http_url”“http://example.com/awesome_space/awesome_project.git”“名称”“可怕的空间”“visibility_level”20.“path_with_namespace”“awesome_space / awesome_project”“default_branch”“主”“主页”“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”“消息”“固定readme”“时间戳”“2012 - 01 - 03 - t23:36:29 + 02:00”“url”“http://example.com/awesome_space/awesome_project/commits/da1560886d4f094c3e6c9ef40349f7d38b5d27d7”“作者”“名称”“GitLab开发用户”“电子邮件”“gitlabdev@dv6700(没有)”。}},“work_in_progress”“url”“http://example.com/diaspora/merge_requests/1”“行动”“开放”“受让人”“名称”“User1”“用户名”“user1”“avatar_url”“http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\ u0026 d = identicon”}},“标签”[{“id”206“标题”“API”“颜色”“# ffffff”“project_id”14“created_at”“2013 - 12 - 03 - t17:15:43z”“updated_at”“2013 - 12 - 03 - t17:15:43z”“模板”“描述”“与空气污染指数有关的事宜”“类型”“ProjectLabel”“group_id”41}),“改变”“updated_by_id”(1],“updated_at”("2017-09-15 16:50:55 utc "2017-09-15 16:52:00 utc],“标签”“以前”[{“id”206“标题”“API”“颜色”“# ffffff”“project_id”14“created_at”“2013 - 12 - 03 - t17:15:43z”“updated_at”“2013 - 12 - 03 - t17:15:43z”“模板”“描述”“与空气污染指数有关的事宜”“类型”“ProjectLabel”“group_id”41}),“当前”[{“id”205“标题”“平台”“颜色”“123123 #”“project_id”14“created_at”“2013 - 12 - 03 - t17:15:43z”“updated_at”“2013 - 12 - 03 - t17:15:43z”“模板”“描述”“平台相关问题”“类型”“ProjectLabel”“group_id”41})}}}

维基页面事件

当创建、更新或删除wiki页面时触发。

请求头

X-Gitlab-Event: Wiki页面钩子

请求体

“object_kind”“wiki_page”“用户”“名称”“管理员”“用户名”“根”“avatar_url”“http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\ u0026 d = identicon”},“项目”“id”1“名称”“了不起的项目”“描述”“这太棒了”“web_url”“http://example.com/root/awesome-project”“avatar_url”“git_ssh_url”“git@example.com:根/ awesome-project.git”“git_http_url”“http://example.com/root/awesome-project.git”“名称”“根”“visibility_level”0“path_with_namespace”“根/了不起的项目”“default_branch”“主”“主页”“http://example.com/root/awesome-project”“url”“git@example.com:根/ awesome-project.git”“ssh_url”“git@example.com:根/ awesome-project.git”“http_url”“http://example.com/root/awesome-project.git”},“维基”“web_url”“http://example.com/root/awesome-project/wikis/home”“git_ssh_url”“git@example.com:根/ awesome-project.wiki.git”“git_http_url”“http://example.com/root/awesome-project.wiki.git”“path_with_namespace”“根/ awesome-project.wiki”“default_branch”“主”},“object_attributes”“标题”“Awesome”一词“内容”“很棒的内容在这里”“格式”“减价”“消息”“给wiki添加一个很棒的页面”“鼻涕虫”“awesome”一词“url”“http://example.com/root/awesome-project/wikis/awesome”“行动”“创造”}}

管道的事件

管线状态改变触发。

请求头

X-Gitlab-Event:管道钩子

请求体

“object_kind”“管道”“object_attributes”: {“id”31“ref”“主”“标签”“沙”“bcbb5ec396a2c0f828686f14fac9b80b780504f2”“before_sha”“bcbb5ec396a2c0f828686f14fac9b80b780504f2”“状态”“成功”“阶段”:[“构建”“测试”“部署”],“created_at”"2016-08-12 15:23:28 utc "“finished_at”"2016-08-12 15:26:29 utc "“持续时间”63},“用户”: {“名称”“管理员”“用户名”“根”“avatar_url”“http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\ u0026 d = identicon”},“项目”: {“id”1“名称”“Gitlab测试”“描述”“在阳光下,爱是一种相似的魅力。”“web_url”“http://192.168.64.1:3005 gitlab-org gitlab-test”“avatar_url”“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”“名称”“Gitlab Org”“visibility_level”20.“path_with_namespace”“gitlab-org gitlab-test”“default_branch”“主”},“提交”: {“id”“bcbb5ec396a2c0f828686f14fac9b80b780504f2”“消息”“测试\ n“时间戳”“2016 - 08 - 12 - t17:23:21 + 02:00”“url”“http://example.com/gitlab-org/gitlab-test/commit/bcbb5ec396a2c0f828686f14fac9b80b780504f2”“作者”: {“名称”“用户”“电子邮件”“user@gitlab.com”}},“构建”:[“id”380“舞台”“部署”“名称”“生产”“状态”“跳过”“created_at”"2016-08-12 15:23:28 utc "“started_at”“finished_at”“当”“手动”“手动”真正的“用户”: {“名称”“管理员”“用户名”“根”“avatar_url”“http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\ u0026 d = identicon”},“跑步者”“artifacts_file”: {“文件名”“大小”}},“id”377“舞台”“测试”“名称”“测试图”“状态”“成功”“created_at”"2016-08-12 15:23:28 utc "“started_at”"2016-08-12 15:26:12 utc "“finished_at”“当”“on_success”“手动”“用户”: {“名称”“管理员”“用户名”“根”“avatar_url”“http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\ u0026 d = identicon”},“跑步者”“artifacts_file”: {“文件名”“大小”}},“id”378“舞台”“测试”“名称”“test-build”“状态”“成功”“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 "“当”“on_success”“手动”“用户”: {“名称”“管理员”“用户名”“根”“avatar_url”“http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\ u0026 d = identicon”},“跑步者”“artifacts_file”: {“文件名”“大小”}},“id”376“舞台”“构建”“名称”“构建过程”“状态”“成功”“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 "“当”“on_success”“手动”“用户”: {“名称”“管理员”“用户名”“根”“avatar_url”“http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\ u0026 d = identicon”},“跑步者”“artifacts_file”: {“文件名”“大小”}},“id”379“舞台”“部署”“名称”“暂存”“状态”“创建”“created_at”"2016-08-12 15:23:28 utc "“started_at”“finished_at”“当”“on_success”“手动”“用户”: {“名称”“管理员”“用户名”“根”“avatar_url”“http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\ u0026 d = identicon”},“跑步者”“artifacts_file”: {“文件名”“大小”}}}

构建事件

在构建的状态更改时触发。

请求头

X-Gitlab-Event:构建钩子

请求体

“object_kind”“构建”“ref”“gitlab-script-trigger”“标签”“before_sha”“2293 ada6b400935a1378653304eaf6221e0fdb8f”“沙”“2293 ada6b400935a1378653304eaf6221e0fdb8f”“build_id”1977“build_name”“测试”“build_stage”“测试”“build_status”“创建”“build_started_at”“build_finished_at”“build_duration”“build_allow_failure”“project_id”380“project_name”“gitlab-org gitlab-test”“用户”“id”3.“名称”“用户”“电子邮件”“user@gitlab.com”},“提交”“id”2366“沙”“2293 ada6b400935a1378653304eaf6221e0fdb8f”“消息”“测试\ n“author_name”“用户”“author_email”“user@gitlab.com”“状态”“创建”“持续时间”“started_at”“finished_at”},“库”“名称”“gitlab_test”“git_ssh_url”“git@192.168.64.1: gitlab-org gitlab-test.git”“描述”“在阳光下,爱是一种相似的魅力。”“主页”“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.}}

测试人

您可以手动触发webhook。将使用项目中的样例数据。样本数据将取自该项目。

例如:用于触发推动事件您的项目应该至少有一次提交。

Webhook测试”class=

解决人

Gitlab存储webhook的每次执行。您可以在每个webhook的编辑页面的“最近交付”部分找到最近2天的记录。

近期交货”class=

在本节中,您可以看到HTTP状态码(绿色表示200-299代码,红色表示其他代码),内部错误对于失败的交付),触发事件,调用事件的时间,请求的经过时间。

如果需要更多关于执行的信息,可以单击查看详细信息链接。在这个页面上,你可以看到GitLab发送的数据(请求头和正文)和它接收的数据(响应头和正文)。

在此页面中,您可以通过单击重复传递相同的数据重新发送请求按钮。

注意:如果webhook的URL或秘密令牌被更新,数据将被传递到新的地址。

接收同一个事件触发的重复或多个web hook请求

当GitLab发送webhook时,它期望在10秒内得到响应(设置默认值)。如果没有收到,它将重试该webhook。如果端点在这10秒内没有发送HTTP响应,GitLab可能会认为钩子失败并重试它。

如果您正在接收多个请求,您可以尝试增加默认值,以便在发送webhook后等待HTTP响应/etc/gitlab/gitlab.rb

Gitlab_rails ['webhook_timeout'] = 10

webhook接收器示例

如果你想看看GitLab的webhooks在测试中的作用,你可以在控制台会话中运行一个简单的echo脚本。要使下面的脚本工作,您需要安装Ruby。

将以下文件保存为print_http_body.rb

需要“webrick”服务器WEBrick::HTTPServer:端口= >ARGV第一个服务器mount_proc' / '|要求的事情res|要求的事情身体结束陷阱“INT”服务器关闭结束服务器开始

选择一个未使用的端口(例如8000)并启动脚本:ruby print_http_body。rb 8000。然后将您的服务器添加为GitLab中的webhook接收器http://my.host:8000/

当你在GitLab中按下“Test”时,你应该在控制台中看到这样的内容:

{“之前”:“077 a85dd266e6f3573ef7e9ef8ce3343ad659c4e”、“后”:“95 cd4a99e93bc4bbabacfa2cd10e6725b1403c60”<剪>}example.com - - [14/May/2014:07:45:26 EDT] "POST / HTTP/1.1" 200- -> /
Baidu
map