The main purpose of Slack notification for Bitbucket app is to increase team visibility and reduce notification noise
Functionality is to notify users about pull requests and push activities. There are global and repository specific configurations. Repository specific configuration can override global settings.
This Bitbucket plugin to handle both cases:
Send slack messages about pull request activity
Also send messages about push operations
This way we don’t need to manage a separate hook for push notifications and yet another plugin for the pull requests.
Getting and installing the plugin
You can grab the latest release from Atlassian Marketplace. Download the jar file and install it into your Bitbucket instance from the manage Apps page.
Configuring the plugin
You need to create an incoming web hook in Slack. Go to slack home using a web browser, and select Add Integrations. Scroll to the bottom, and select Incoming WebHooks (click on Add). This will generate the hook url.
Bitbucket notifications to Slack plugin configuration
There are two places for the configuration. First is the global setting page that you can access from the Bitbucket administration. Here you can setup the defaults or settings for ALL repositories (they can be override on the repository level).
Below you can see pull request notifications.
Bitbucket repository push notifications.
Additionally, you can setup Channels and branches patterns. Using this setting you can configure which Slack channel should be used for notifications about events in particular branch(s).
It accepts a single channel name (example: #it-admins), or you can add a comma separated list of pairs (pattern->channel). In this case the format must be: PATTERN->CHANNELNAME,ANOTHERPATTERN->ANOTHERCHANNELNAME. Pattern will match against the current ref name ignoring the "refs/heads" part. For instance, if you want to match refs/heads/bugfix/mybug42 and all other bugfix branches, add a pattern as bugfix/.* You can also leave it empty. When empty, the default channel will be used within the webhook.
Note: the branch filter is an event destination branch (“to” branch selected by default). It is important for some pull requests events.
For instance, if you want to be notified when the pull request is merged and filter by branch. You have to use the destination branch (“to” branch).
The from branch is used to filter by the source branch. Normally, it is used for the pull requests activities.
For example, I’ve got a branch issue/DEV-564-slack-card-refactoring and I want to receive notifications about PR comments to slack into my channel. I will setup `issue/DEV-564-slack-card-refactoring->#pull-request-comments`.
You have the option to enable notifications on a per repository basis. Go to your repository settings page, select Slack settings and enable pull request and/or push notifications with the check boxes. You can override here the default global settings.
There are 4 additional filters are present:
users that triggered the events (users whitelist).
users that triggered the events and should be ignored (users blacklist).
user groups a user that had triggered an event should belong to (user groups whitelist).
user groups a user that had triggered an event should belong to and will be ignored (user groups blacklist).
Override settings for global slack notification options - If enabled, Slack notifications will use the settings defined on the repository level instead of global settings. This flag overrides pull request filters or push notification options. Note, if you enable the flag, you MUST set a channel name as well (only the hook is not required).
Here is an example screenshot about the push notifications: