Adding webhooks and webhook invocation to RB-Gateway
Review Request #9402 — Created Nov. 26, 2017 and discarded
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 https://www.notion.so/reviewboard/RB-Gateway-Webhooks-29b5037924d14aff83e2b53b86087a23 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 https://requestb.in/ as a receiving url. Try running rb-gateway to makesure config.json is parsed correctly.
Second, configure the sample hookscript: "sample_Git_post-commit_hookscript.sh". 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.
Description | From | Last Updated |
---|---|---|
Payload is laid out in nice columns, but Commit and Webhook aren't. This might be because your text editor is … |
RC rcreagha | |
The trailing whitespace should be removed from this line. |
RC rcreagha |
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 2 (+109) |
Checks run (2 succeeded)
-
-
webhook.go (Diff revision 2) Payload
is laid out in nice columns, butCommit
andWebhook
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. -
Change Summary:
- rb-gateway post-commit webhooks are now Invokable
- Added in command line flags to send hook data to rb-gateway to invoke appropriately registered post-commit webhooks.
- Added in basic webhook validation and webhook registration.
- Refactored and added to util.go to allow saving of config.json.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 3 (+288 -19) |
Checks run (2 succeeded)
Change Summary:
deleted some white space
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 4 (+288 -19) |
Checks run (2 succeeded)
Description: |
|
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
||||||||||||||||||
Commit: |
|
||||||||||||||||||
Diff: |
Revision 5 (+302 -19) |
Checks run (2 succeeded)
Description: |
|
---|
Description: |
|
---|
Change Summary:
Changed the config file path to come from path of rb-gateway because it used to assume the config file was in the same folder as the caller of rb-gateway. This was a problem when hookscripts in a different folder attempted to call rb-gateway.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 6 (+314 -20) |
Checks run (2 succeeded)
Summary: |
|
||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description: |
|
||||||||||||||||||||||||
Testing Done: |
|
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 7 (+314 -20) |