Recent Changes

2021-07-26
2021-03-17
2021-03-08
2021-03-03
2021-01-22
2021-01-21

Repository Webhooks

About Webhooks

When you are using code repository locally, you can install hooks for all kinds of actions. In the same manner, at OSDN, you can use “Webhooks”.

To be more specific, when you are pushing (in the case of svn, committing), you will be converting the contents to JSON format and POST it on the assigned URL. At the destination of the POST, you can interpret JSON to request whatever action you like.

How to Set Up a Webhook

Login as admin of the project or chamber, then go to the repository browser and choose the submenu “hook settings” to set up.

Data to be Sent

The data structure is designed to be similar to that of github. However currently, it does not contain each commit information that exist in the push data.

Like general HTML format, data is in the form of Content-Disposiotn: form-data, and gets sent in Post method. It has a key called “payload”. The inside is JSON format.

Example of Data to be Sent

  1. {
  2. "after": "6829ef8417b4d6c7cb20f4a34b6ccf4cb97dabe2",
  3. "before": "6789be548cc0d16a94f6d128ff813b64184ba549",
  4. "head_commit": {
  5. "author": {
  6. "email": "sugi@nemui.org",
  7. "name": "Tatsuki Sugiura"
  8. },
  9. "id": "6829ef8417b4d6c7cb20f4a34b6ccf4cb97dabe2",
  10. "message": "Test!\n",
  11. "timestamp": "2013-06-07T17:34:49",
  12. "url": "https://osdn.net/users/sugi/pf/sugitest/commits/6829ef8417b4d6c7cb20f4a34b6ccf4cb97dabe2"
  13. },
  14. "pusher": "sugi",
  15. "ref": "refs/heads/master",
  16. "repository": {
  17. "created_at": 1291198691,
  18. "description": "<i> test",
  19. "id": "6",
  20. "name": "sugitest",
  21. "pushed_at": 1370594094,
  22. "type": "git",
  23. "url": "https://osdn.net/users/sugi/pf/sugitest/"
  24. }
  25. }

Data Fields and Definitions

Fields githgsvn
after Commit ID after pushing The Commit ID after (of the final) pushing Committed Revision
before Commit ID before pushing The first Commit ID of the push null
head_commit Commit information of the after's ID Commit information of the after's ID Commit information
pusher OSDN user ID
ref Ref of the destination of the push The branch name of the push The directory path that has been changed
repository Repository Information

Testing Webhooks

Press the “test” button to execute the hook request using the lastly pushed information. By using requestbin and the likes, you can confirm the data that will be sent.

Notices, Restrictions

  • Webhook is not designed for realtime execution.
  • When multiple pushes are rushed consecutively in short period of time, there's no guarantee the webhooks will be executed in chronological order.
  • In the system, once there's a push (commit), it will be in the queue waiting to be executed within a few minutes. When you need time for pushing, read repository.pushed_at in the data.
  • For each hook, you can switch between active and disable any time. Disabled hooks are simply skipped.
  • When there are errors in the hook, there won't be another trial, and simply gets logged as error.
  • When there are more than 10 errors, that hook gets automatically disabled.