Web 钩子

Gogs 支持针对仓库事件的 Web 钩子服务,您可以在仓库的设置相关页面中找到(/:username/:reponame/settings/hooks)。所有的事件推送均为 POST 请求,目前支持 Gogs 和 Slack 两种格式的内容。

事件信息

以下为 Gogs 向 Payload URL 发送的事件信息示例:

  1. X-Gogs-Delivery: f6266f16-1bf3-46a5-9ea4-602e06ead473
  2. X-Gogs-Event: push
  3. X-Gogs-Signature: 1921679ed6274399b6514721056337f6913b6ff1cb35a24d340e983745d637f1
  1. {
  2. "ref": "refs/heads/develop",
  3. "before": "28e1879d029cb852e4844d9c718537df08844e03",
  4. "after": "bffeb74224043ba2feb48d137756c8a9331c449a",
  5. "compare_url": "http://localhost:3000/unknwon/webhooks/compare/28e1879d029cb852e4844d9c718537df08844e03...bffeb74224043ba2feb48d137756c8a9331c449a",
  6. "commits": [
  7. {
  8. "id": "bffeb74224043ba2feb48d137756c8a9331c449a",
  9. "message": "!@#0^%\u003e\u003e\u003e\u003e\u003c\u003c\u003c\u003c\u003e\u003e\u003e\u003e\n",
  10. "url": "http://localhost:3000/unknwon/webhooks/commit/bffeb74224043ba2feb48d137756c8a9331c449a",
  11. "author": {
  12. "name": "Unknwon",
  13. "email": "u@gogs.io",
  14. "username": "unknwon"
  15. },
  16. "committer": {
  17. "name": "Unknwon",
  18. "email": "u@gogs.io",
  19. "username": "unknwon"
  20. },
  21. "timestamp": "2017-03-13T13:52:11-04:00"
  22. }
  23. ],
  24. "repository": {
  25. "id": 140,
  26. "owner": {
  27. "id": 1,
  28. "login": "unknwon",
  29. "full_name": "Unknwon",
  30. "email": "u@gogs.io",
  31. "avatar_url": "https://secure.gravatar.com/avatar/d8b2871cdac01b57bbda23716cc03b96",
  32. "username": "unknwon"
  33. },
  34. "name": "webhooks",
  35. "full_name": "unknwon/webhooks",
  36. "description": "",
  37. "private": false,
  38. "fork": false,
  39. "html_url": "http://localhost:3000/unknwon/webhooks",
  40. "ssh_url": "ssh://unknwon@localhost:2222/unknwon/webhooks.git",
  41. "clone_url": "http://localhost:3000/unknwon/webhooks.git",
  42. "website": "",
  43. "stars_count": 0,
  44. "forks_count": 1,
  45. "watchers_count": 1,
  46. "open_issues_count": 7,
  47. "default_branch": "master",
  48. "created_at": "2017-02-26T04:29:06-05:00",
  49. "updated_at": "2017-03-13T13:51:58-04:00"
  50. },
  51. "pusher": {
  52. "id": 1,
  53. "login": "unknwon",
  54. "full_name": "Unknwon",
  55. "email": "u@gogs.io",
  56. "avatar_url": "https://secure.gravatar.com/avatar/d8b2871cdac01b57bbda23716cc03b96",
  57. "username": "unknwon"
  58. },
  59. "sender": {
  60. "id": 1,
  61. "login": "unknwon",
  62. "full_name": "Unknwon",
  63. "email": "u@gogs.io",
  64. "avatar_url": "https://secure.gravatar.com/avatar/d8b2871cdac01b57bbda23716cc03b96",
  65. "username": "unknwon"
  66. }
  67. }