Bitbucket Slack channel and hook overrides using patterns

In order to receive Slack notifications to different Bitbucket branches you need to create a pattern expression against source (from) or destination (to) branch.
January 3, 2022
Productivity
Use-Case

Question

I am integrating Bitbucket Data Center and Slack. I am trying to set up Slack notifications using the pattern option wherein all the Bitbucket pull requests to master should go to one Slack channel, and pull requests to bugfix should go to another channel. I am using this pattern master->#bb-master,bugfix->#bb-bug-prs


Answer

The setup is pretty easy to achieve this. The main issue here is to understand the source (from) and destination (to) branches.


The source branch is where you have your source code, and the destination branch is where you want to merge your pull request. In the question above, you create a bug pull request with a destination branch bugfix. You create pull requests with the master as a destination when you want to merge there.


Let us show you how to set this up with App "Slack notifications for Bitbucket" by Move Work Forward.

Our initial setup is that we have 2 Slack channels - #bb-master for the pull requests with the master branch as a destination and #bb-bug-prs for the Bitbucket pull requests for the bug fixes. We usually name those bugfix/DEV-123-bug-description, where DEV-123 is the Jira issue key.

Afterwards, we create an Incoming Webhook for the #bb-master branch only.

Bitbucket and Slack integration
We configure a repository config with the following pattern master->#bb-master,bugfix->#bb-bug-prs.
Bitbucket and Slack integration

After we configured the rule we created 2 Bitbucket pull requests: one against the master and another against the bugfix branch.

Bitbucket and Slack integration

When the pull requests created or merged the corresponding Slack channels will get notified.

Bitbucket and Slack integration

Important: You need to pay close attention when to use From branch or To branch setting.

Try our Slack notifications for Bitbucket App. Please reach out if you have any questions or doubts.

Products we’re proud of

Articles you might like

Atlassian announces a new partnership with Slack
December 16, 2020
Atlassian announces a new partnership with Slack
Atlassian has made an equity investment in Slack, and Slack has acquired the IP for Stride and HipChat Cloud. Slack has been a user of Atlassian products for many years, and Atlassian's employees are using Slack now. Microsoft Teams is an option as well.
Read more >
How to integrate Bitbucket Server with Jenkins Pipelines
December 16, 2020
How to integrate Bitbucket Server with Jenkins Pipelines
We want to automate project build using a Parametrised Jenkins Pipeline of the source code stored in Bitbucket Server.
Read more >

New blog posts

Thinking Big
June 13, 2022
Thinking Big
In today's world, thinking big is not an optional choice anymore. You either proactively solve for the world scale or not, you either broaden your thinking or you loose.
Read more >
Jira Development Panel for GitHub and GitLab
May 11, 2022
Jira Development Panel for GitHub and GitLab
Have you thought about connecting GitLab or GitHub to Jira to easily create feature branches and 1-click jump to the branches and pull requests related to a Jira issue? You can do this by connecting GitHub, GitLab or Gerrit using Jigit app that integrates git system with Jira On-Premises. Please read on if you are interested to see how it looks and how this integration can benefit you and your team.
Read more >
Azure DevOps Confluence Data Center Connector
April 12, 2022
Azure DevOps Confluence Data Center Connector
Learn here how to improve your technical documentation in Confluence Data Center running On-Premises and bring real-time information from Azure DevOps into Confluence pages and blog posts.
Read more >