Setting up a repository hook with JSON
The use the notification hook in Notifyr a JSON configuration must be added to the root of your source code. The advantage of having a JSON file that is part of your source code is that:
- You can include a default setting in your project architecture.
- Developers can include their own notification if required
- Much more flexibility on type of notifications based on branches
Prepare your repository for the notification hook
For a repository to use the notification hook, a JSON file named
notifications.json needs to be added to the root of the repository. A bare minimum
notifications.json file would looks like this:
The above configuration would send a notification to
[email protected] for every push made to the repository.
The JSON configuration has more options and flexibility in when to send what kind of notification and to who. Take the following configuration for example:
There are a few thing happening here, but first thing you might noticed is that you are able to specify multiple rules. Let's explain the options
|match||An Ant based pattern to match your branch against|
an array of notifications:
Enable to Notification Hook
Repository administrators can setup the hooks that are available in Bitbucket by going to Settings > Hooks for a Bitbucket repository. Once installed, hooks are available across all repositories in a Bitbucketinstance, but are enabled separately on each repository in a project.
To setup the Notification Hook:
- Browse to the Hooks overview in your repository settings
- Browse to the relevant repository
- Choose Settings from the repository navigation
- Select Hooks from the left menu
- Toggle the Notifyr - Notification Hook setting to Enabled.