WebHook 推送数据格式说明

WebHook的数据类型,具体查看:WebHook 推送数据的数据类型说明

用户可以通过自建服务接收来自 Gitee WebHook 的消息,相关 WebHook 推送数据格式的说明如下:

Request Headers

WebHook request headers 包含以下一些关键数据

Content-Type: application/json # 默认为 application/json , 若是旧版钩子(已不维护)为 application/x-www-form-urlencoded  User-Agent: git-oschina-hook    # 固定为 git-oschina-hook,可用于标识为来自 gitee 的请求  X-Gitee-Token: webhook password/sign  # 用户新建 WebHook 时提供的密码或根据提供的签名密钥计算后的签名  X-Gitee-Timestamp: 1576754827988  # 触发 WebHook 的时间戳  X-Gitee-Event: Merge Request Hook # 标识触发的钩子类型

X-Gitee-Token 签名密钥计算签名的实现算法可参考:《WebHook 密钥验证和验证算法

Request Payload

Webhook request payload 根据不同钩子,分为 4 种类型 payload, 以下是各钩子推送的示范数据(仅供参考,请以实际收到的数据为准)

Push / Tag Push 钩子

以下是一次推送代码触发的钩子数据

{  "hook_name": "push_hooks",   "password": "pwd",  "hook_id": 1,  "hook_url": "http://gitee.com/liwen/gitos/hooks/1/edit",  "timestamp": "1576754827988",  "sign": "rLEHLuZRIQHuTPeXMib9Czoq9dVXO4TsQcmQQHtjXHA=",  "ref": "refs/heads/change_commitlint_config",  "before": "0000000000000000000000000000000000000000",  "after": "1cdcd819599cbb4099289dbbec762452f006cb40",  "created": true,  "deleted": false,  "compare": "https://gitee.com/oschina/gitee/compare/0000000000000000000000000000000000000000...1cdcd819599cbb4099289dbbec762452f006cb40",  "commits": [  {  "id": "1cdcd819599cbb4099289dbbec762452f006cb40",  "tree_id": "db78f3594ec0683f5d857ef731df0d860f14f2b2",  "distinct": true,  "message": "Update README.md",  "timestamp": "2018-02-05T23:46:46+08:00",  "url": "https://gitee.com/oschina/gitee/commit/1cdcd819599cbb4099289dbbec762452f006cb40",  "author": {  "time": "2018-02-05T23:46:46+08:00",  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "committer": {  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "added": null,  "removed": null,  "modified": [  "README.md"  ]  }  ],  "head_commit": {  "id": "1cdcd819599cbb4099289dbbec762452f006cb40",  "tree_id": "db78f3594ec0683f5d857ef731df0d860f14f2b2",  "distinct": true,  "message": "Update README.md",  "timestamp": "2018-02-05T23:46:46+08:00",  "url": "https://gitee.com/oschina/gitee/commit/1cdcd819599cbb4099289dbbec762452f006cb40",  "author": {  "time": "2018-02-05T23:46:46+08:00",  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "committer": {  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "added": null,  "removed": null,  "modified": [  "README.md"  ]  },  "total_commits_count": 0,  "commits_more_than_ten": false,  "repository": {  "id": 120249025,  "name": "Gitee",  "path": "gitee",  "full_name": "开源中国/Gitee",  "owner": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "private": false,  "html_url": "https://gitee.com/oschina/gitee",  "url": "https://gitee.com/oschina/gitee",  "description": "",  "fork": false,  "created_at": "2018-02-05T23:46:46+08:00",  "updated_at": "2018-02-05T23:46:46+08:00",  "pushed_at": "2018-02-05T23:46:46+08:00",  "git_url": "git://gitee.com:oschina/gitee.git",  "ssh_url": "git@gitee.com:oschina/gitee.git",  "clone_url": "https://gitee.com/oschina/gitee.git",  "svn_url": "svn://gitee.com/oschina/gitee",  "git_http_url": "https://gitee.com/oschina/gitee.git",  "git_ssh_url": "git@gitee.com:oschina/gitee.git",  "git_svn_url": "svn://gitee.com/oschina/gitee",  "homepage": null,  "stargazers_count": 11,  "watchers_count": 12,  "forks_count": 0,  "language": "ruby",  "has_issues": true,  "has_wiki": true,  "has_pages": false,  "license": null,  "open_issues_count": 0,  "default_branch": "master",  "namespace": "oschina",  "name_with_namespace": "开源中国/Gitee",  "path_with_namespace": "oschina/gitee"  },  "sender": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "enterprise": {  "name": "开源中国",  "url": "https://gitee.com/oschina"  } }

Issue 钩子

以下是一次新建任务操作触发的钩子数据

{  "hook_name": "issue_hooks",   "password": "pwd",  "hook_id": 1,  "hook_url": "http://gitee.com/liwen/gitos/hooks/1/edit",  "timestamp": "1576754827988",  "sign": "rLEHLuZRIQHuTPeXMib9Czoq9dVXO4TsQcmQQHtjXHA=",  "issue": {  "html_url": "https://gitee.com/oschina/gitee/issues/IG6E9",  "id": 295024870,  "number": "IG6E9",  "title": "IE浏览器,js报错",  "body": "新建任务js报错",  "state": "open",  "comments": 0,  "created_at": "2018-02-07T23:46:46+08:00",  "updated_at": "2018-02-07T23:46:46+08:00",  "user": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "labels": [  {  "id": 827033694,  "name": "bug",  "color": "d73a4a"  }  ],  "assignee": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "milestone": {  "html_url": "https://gitee.com/oschina/gitee/milestones/1",  "id": 3096855,  "number": 1,  "title": "问题反馈",  "description": null,  "open_issues": 13,  "started_issues": 6,  "closed_issues": 31,  "approved_issues": 42,  "state": "open",  "created_at": "2018-02-01T23:46:46+08:00",  "updated_at": "2018-02-02T23:46:46+08:00",  "due_on": null  }  },  "repository": {  "id": 120249025,  "name": "Gitee",  "path": "gitee",  "full_name": "开源中国/Gitee",  "owner": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "private": false,  "html_url": "https://gitee.com/oschina/gitee",  "url": "https://gitee.com/oschina/gitee",  "description": "",  "fork": false,  "created_at": "2018-02-05T23:46:46+08:00",  "updated_at": "2018-02-05T23:46:46+08:00",  "pushed_at": "2018-02-05T23:46:46+08:00",  "git_url": "git://gitee.com:oschina/gitee.git",  "ssh_url": "git@gitee.com:oschina/gitee.git",  "clone_url": "https://gitee.com/oschina/gitee.git",  "svn_url": "svn://gitee.com/oschina/gitee",  "git_http_url": "https://gitee.com/oschina/gitee.git",  "git_ssh_url": "git@gitee.com:oschina/gitee.git",  "git_svn_url": "svn://gitee.com/oschina/gitee",  "homepage": null,  "stargazers_count": 11,  "watchers_count": 12,  "forks_count": 0,  "language": "ruby",  "has_issues": true,  "has_wiki": true,  "has_pages": false,  "license": null,  "open_issues_count": 0,  "default_branch": "master",  "namespace": "oschina",  "name_with_namespace": "开源中国/Gitee",  "path_with_namespace": "oschina/gitee"  },  "sender": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "enterprise": {  "name": "开源中国",  "url": "https://gitee.com/oschina"  } }

Pull Request 钩子

以下是一次提交 Pull Request 触发的钩子数据

{  "hook_name": "merge_request_hooks",   "password": "pwd",  "hook_id": 1,  "hook_url": "http://gitee.com/liwen/gitos/hooks/1/edit",  "timestamp": "1576754827988",  "sign": "rLEHLuZRIQHuTPeXMib9Czoq9dVXO4TsQcmQQHtjXHA=",  "pull_request": {  "id": 167750879,  "number": 1,  "state": "open",  "html_url": "https://gitee.com/oschina/giteeb/pulls/1",  "diff_url": "https://gitee.com/oschina/giteeb/pulls/1.diff",  "patch_url": "https://gitee.com/oschina/giteeb/pulls/1.patch",  "title": "三方登陆的账号无密码问题",  "body": null,  "created_at": "2018-02-07T23:46:46+08:00",  "updated_at": "2018-02-07T23:46:46+08:00",  "closed_at": null,  "merged_at": null,  "merge_commit_sha": "5ccc31cda7aad7ddc59a6bdbb8a8bd61959dc71c",  "user": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "assignee": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "tester": null,  "milestone": {  "html_url": "https://gitee.com/oschina/gitee/milestones/1",  "id": 3096855,  "number": 1,  "title": "问题反馈",  "description": null,  "open_issues": 13,  "started_issues": 6,  "closed_issues": 31,  "approved_issues": 42,  "state": "open",  "created_at": "2018-02-01T23:46:46+08:00",  "updated_at": "2018-02-02T23:46:46+08:00",  "due_on": null  },  "head": {  "label": "gitee:login_should_complete_info",  "ref": "login_should_complete_info",  "sha": "5ccc31cda7aad7ddc59a6bdbb8a8bd61959dc71c",  "user": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "repo": {  "id": 120249025,  "name": "Gitee",  "path": "gitee",  "full_name": "开源中国/Gitee",  "owner": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "private": false,  "html_url": "https://gitee.com/oschina/gitee",  "url": "https://gitee.com/oschina/gitee",  "description": "",  "fork": false,  "created_at": "2018-02-05T23:46:46+08:00",  "updated_at": "2018-02-05T23:46:46+08:00",  "pushed_at": "2018-02-05T23:46:46+08:00",  "git_url": "git://gitee.com:oschina/gitee.git",  "ssh_url": "git@gitee.com:oschina/gitee.git",  "clone_url": "https://gitee.com/oschina/gitee.git",  "svn_url": "svn://gitee.com/oschina/gitee",  "git_http_url": "https://gitee.com/oschina/gitee.git",  "git_ssh_url": "git@gitee.com:oschina/gitee.git",  "git_svn_url": "svn://gitee.com/oschina/gitee",  "homepage": null,  "stargazers_count": 11,  "watchers_count": 12,  "forks_count": 0,  "language": "ruby",  "has_issues": true,  "has_wiki": true,  "has_pages": false,  "license": null,  "open_issues_count": 0,  "default_branch": "master",  "namespace": "oschina",  "name_with_namespace": "开源中国/Gitee",  "path_with_namespace": "oschina/gitee"  }  },  "base": {  "label": "gitee:master",  "ref": "master",  "sha": "7324ba0e3f19236bf4ddc6003168fbddf8f723a5",  "user": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "repo": {  "id": 120249025,  "name": "Gitee",  "path": "gitee",  "full_name": "开源中国/Gitee",  "owner": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "private": false,  "html_url": "https://gitee.com/oschina/gitee",  "url": "https://gitee.com/oschina/gitee",  "description": "",  "fork": false,  "created_at": "2018-02-05T23:46:46+08:00",  "updated_at": "2018-02-05T23:46:46+08:00",  "pushed_at": "2018-02-05T23:46:46+08:00",  "git_url": "git://gitee.com:oschina/gitee.git",  "ssh_url": "git@gitee.com:oschina/gitee.git",  "clone_url": "https://gitee.com/oschina/gitee.git",  "svn_url": "svn://gitee.com/oschina/gitee",  "git_http_url": "https://gitee.com/oschina/gitee.git",  "git_ssh_url": "git@gitee.com:oschina/gitee.git",  "git_svn_url": "svn://gitee.com/oschina/gitee",  "homepage": null,  "stargazers_count": 11,  "watchers_count": 12,  "forks_count": 0,  "language": "ruby",  "has_issues": true,  "has_wiki": true,  "has_pages": false,  "license": null,  "open_issues_count": 0,  "default_branch": "master",  "namespace": "oschina",  "name_with_namespace": "开源中国/Gitee",  "path_with_namespace": "oschina/gitee"  }  },  "merged": false,  "mergeable": null,  "comments": 0,  "commits": 1,  "additions": 7,  "deletions": 0,  "changed_files": 1  },  "author": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "sender": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "enterprise": {  "name": "开源中国",  "url": "https://gitee.com/oschina"  } }

评论钩子

以下是一次评论任务操作触发的钩子数据,其中 notable_type 表示评论的不同类型: Comment(仓库评论)、Commit、PullRequest、Issue

{  "hook_name": "note_hooks",   "password": "pwd",  "hook_id": 1,  "hook_url": "http://gitee.com/liwen/gitos/hooks/1/edit",  "timestamp": "1576754827988",  "sign": "rLEHLuZRIQHuTPeXMib9Czoq9dVXO4TsQcmQQHtjXHA=",  "comment": {  "html_url": "https://gitee.com/oschina/gitee/issues/IG6E9#note_1",  "id": 1,  "body": "Fixed",  "user": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "created_at": "2018-02-08T23:46:46+08:00",  "updated_at": "2018-02-08T23:46:46+08:00"  },  "noteable_type": "Issue",   "issue": {  "html_url": "https://gitee.com/oschina/gitee/issues/IG6E9",  "id": 295024870,  "number": "IG6E9",  "title": "IE浏览器,js报错",  "user": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "labels": [  {  "id": 827033694,  "name": "bug",  "color": "d73a4a"  }  ],  "state": "open",  "assignee": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "milestone": {  "html_url": "https://gitee.com/oschina/gitee/milestones/1",  "id": 3096855,  "number": 1,  "title": "问题反馈",  "description": null,  "open_issues": 13,  "started_issues": 6,  "closed_issues": 31,  "approved_issues": 42,  "state": "open",  "created_at": "2018-02-01T23:46:46+08:00",  "updated_at": "2018-02-02T23:46:46+08:00",  "due_on": null  },  "comments": 0,  "created_at": "2018-02-07T23:46:46+08:00",  "updated_at": "2018-02-07T23:46:46+08:00",  "body": "新建任务js报错"  },  "repository": {  "id": 120249025,  "name": "Gitee",  "path": "gitee",  "full_name": "开源中国/Gitee",  "owner": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "private": false,  "html_url": "https://gitee.com/oschina/gitee",  "url": "https://gitee.com/oschina/gitee",  "description": "",  "fork": false,  "created_at": "2018-02-05T23:46:46+08:00",  "updated_at": "2018-02-05T23:46:46+08:00",  "pushed_at": "2018-02-05T23:46:46+08:00",  "git_url": "git://gitee.com:oschina/gitee.git",  "ssh_url": "git@gitee.com:oschina/gitee.git",  "clone_url": "https://gitee.com/oschina/gitee.git",  "svn_url": "svn://gitee.com/oschina/gitee",  "git_http_url": "https://gitee.com/oschina/gitee.git",  "git_ssh_url": "git@gitee.com:oschina/gitee.git",  "git_svn_url": "svn://gitee.com/oschina/gitee",  "homepage": null,  "stargazers_count": 11,  "watchers_count": 12,  "forks_count": 0,  "language": "ruby",  "has_issues": true,  "has_wiki": true,  "has_pages": false,  "license": null,  "open_issues_count": 0,  "default_branch": "master",  "namespace": "oschina",  "name_with_namespace": "开源中国/Gitee",  "path_with_namespace": "oschina/gitee"  },  "sender": {  "id": 1,  "login": "robot",  "avatar_url": "https://gitee.com/assets/favicon.ico",  "html_url": "https://gitee.com/robot",  "type": "User",  "site_admin": false,  "name": "robot",  "email": "robot@gitee.com",  "username": "robot",  "user_name": "robot",  "url": "https://gitee.com/robot"  },  "enterprise": {  "name": "开源中国",  "url": "https://gitee.com/oschina"  } }