Using GitHub, GitLab and Bitbucket commit hooks

  • Last updated on November 18, 2020 at 12:37 AM

You can use commit hooks to update bugs quickly from commit log messages. That way, you can say things like "Changed X to Y, this fixes BH-123" and it will update your BugHerd bug 123 with that message, and change the state to "done". Commit hooks are currently available for GitHub and Bitbucket.

Here's how it works:

  • If you reference any valid bug number, preceded by BH- the commit message will be added to that bug. For example: "Some changes related to BH-1"
  • Using the word "closed", "closes", or "close" just before the bug reference, will change the state to "closed". Example: "Closes BH-1"
  • Using the words "fixed", "fixes, or "fix" just before the bug reference, will change the state to "done". Example: "Fixes BH-1"
  • You can reference multiple bugs at once by separating references with a comma. Example: "Fixes BH-1,2,3".
  • You can make multiple references and phrases in the same message. Example: "Fixed BH-1,2. Started BH-3"
The bug(s) will be updated when the commit is pushed to any branch, the first time only.

Configuration

Go to the BugHerd project you wish to connect and select commit hook from the project menu. 

Screen_Shot_2019-04-15_at_3.34.50_pm.png

This will open the commit hook setup screen:

Screen_Shot_2019-06-03_at_5.44.44_pm.png

Copy the GitHub Webhook URL from the text box, then open GitHub, go to the project you administer and click Settings. Under Webhooks, click Add Webhook and paste the webhook URL in the Payload URL field. Select the Content Type as 'application/json' and click Save

Screen_Shot_2019-04-15_at_3.32.44_pm.png

For Bitbucket, copy the webhook provided and go to Settings > Webhooks.
Give your webhook a title and then paste the Bitbucket webhook URL into the URL field.

Screen_Shot_2019-04-15_at_3.28.26_pm.png

Please ensure you have the Active box ticked and click Save when done.

For GitLab, copy the webhook provided and go to Settings > Integrations, tick the `push events` trigger and click save.

Screen_Shot_2019-06-03_at_5.09.12_pm.png