Adding webhooks and webhook invocation to RB-Gateway

Review Request #9402 — Created Nov. 26, 2017 and updated

rb-gateway, students

Adding the ability to register and invoke webhooks to RB-Gateway will allow the service to notify a url of repository events. Currently this project involves adding code to rb-gateway for configuring and invoking webhooks and adding in a rb-gateway command to invoke webhooks and integrate into repository hook scripts. see for more project details (this review request covers task 1 and 2).

Webhooks can now be registered into config.json. Functions to register webhooks into the config and saving of the config have been implemented but have not yet been hooked up into routes.go.

Webhooks can be invoked by calling a send-webhook command of rb-gateway while passing appropriate data. Currently only post-commit events are supported.

A sample hookscript for invoking rb-gateway webhooks for git repository post-commit events has been included.

Currently there are no automated tests for testing the new features but they are testable by running the sample git post-commit hookscript:
First, configure the config.json appropriately using the sample_config.json as a base. for the sample webhook Configuration url, you can use as a receiving url. Try running rb-gateway to makesure config.json is parsed correctly.
Second, configure the sample hookscript: "". Make sure the repo name field and path to rb-gateway is correct and that the file is executable. You can test out the webhook invocation simply by running the script or installing it into your repository. It won't do anything if your repo has no commits yet. This testing method only works for git repos for now unless you modify the hookscript to be compatible with other scms.

  • 0
  • 0
  • 2
  • 0
  • 2
Description From Last Updated
  1. I don't know Go, but everything looks pretty good from what I can tell. I just have a couple small stylistic issues.

  2. webhook.go (Diff revision 2)

    Payload is laid out in nice columns, but Commit and Webhook aren't. This might be because your text editor is set to use smaller tabs than reviewboard's diff viewer.

    It looks like the file git_repository.go avoids issues from different tab settings by using spaces instead.

  3. webhook.go (Diff revision 2)

    The trailing whitespace should be removed from this line.

Review request changed




Revision 7 (+314 -20)

Show changes

Checks run (2 succeeded)

flake8 passed.
JSHint passed.