Integrate Bitbucket Cloud with Slack

We'll help you & your colleagues stay up to date with everything happening in your Bitbucket. You'll always know:

  • If that pull request got approved

  • When the build finished and if it succeeded or failed

  • When a new branch is added to a repository

  • Much more

Even better, some notifications allow you or your colleagues to take an action right from a notification: 

  • Nudge outstanding reviewers on your pull requests

  • Reply when someone makes a new comment on your issue tracker, a commit, or pull request

  • Merge that pull request now that it's approved

  • Re-run a failed Pipelines build

All that should get you and your colleagues started. We'll be building more awesome into this app based on your feedback!

Install the app

  1. Open the repository you wish to configure notifications for.

  2. Click Repository settings then select Slack > Settings.

  3. Press the Connect button under Slack. A dialog for Slack login might open if you are not already logged in.

  4. Choose the Slack workspace to connect to your repository.

You should receive an automated welcome message in Slack.

If your repository uses the prior Slack integration

If your repository is already set up to trigger notifications for Slack, we recommend that you deconfigure the integration to avoid duplicate notifications. You can stop these notifications from either Bitbucket or Slack.

From Bitbucket, remove the repository's Slack webhooks:

  1. From Repository settings, click Webhooks.

  2. Click Delete for the webhooks configured for Slack.

From Slack, remove the Bitbucket app:

  1. From the Slack App Directory, click Manage.

  2. Find the Bitbucket app (with the old logo) and remove the app.

Subscribe Slack channels to Bitbucket repositories

Add subscriptions to your Slack channels and choose the specific notifications for that subscription. A subscription links your Bitbucket repository to a Slack channel so you can define which Bitbucket events drive notifications for that channel.

You'll need repository administrator permissions to add or modify notifications.

  1. Log into Bitbucket.

  2. Open a specific repository to add notifications to, in the account that is connected to Slack.

  3. Click Repository settings then select Slack > Settings.

  4. Choose one of the following:

    1. Click Add subscription, if you've already connected this repository to Slack.

    2. Click the connect button, if this the first time your connecting a repository to your Slack workspace.

    3. Click Add subscription and then select Add new workspace, if you’re adding a new subscription, to a new workspace.

  5. Choose the Slack workspace and channel to connect to your repository.

You can subscribe to additional repositories via Slack > Settings, or by typing
/bitbucket connect <repository URL> in a Slack workspace that has been previously connected to Bitbucket.

Create subscriptions for private channels

By default, private channels aren't displayed in the channel selector in the subscription creation dialog. However you can create a subscription for any private channel that you have access to by typing /bitbucket connect <repository URL> within that channel.

Create subscriptions in a DM

You can also have notifications sent only to you by direct message from the Bitbucket Slack bot. To create a subscription in a DM, click on the Bitbucket bot in the Apps section of your Slack's left sidebar, and send it the message /bitbucket connect <repository URL>.

Set notifications for each subscription

After you've installed the app you can choose specific notifications in the settings for each repository. You can even select specific branches to get notifications from so you only get what you want in your channels.

  1. Open one of the repositories you connected to Slack.

  2. Click Repository settings. 

  3. Select Slack > Settings.

  4. Select a specific branch, set a branch pattern, or select repository wide to get notifications for all branches.
    Note: It can be helpful to select specific notifications for specific branches. For example you might not want notifications for every commit from every branch but might want exactly that for your production branch.

  5. Select the notifications you want for the branch or branches you select.

Branch patterns for notifications

Selecting a branch pattern allows you and any members of your workspace to continuously receive notifications on all new branches which match a specific pattern. This can be especially helpful in branch heavy workflows.

You can set notifications for a specific pattern of branch name like projectname* or a prefix like DEV* or DEV/**/rocket*. for a complete list of patterns use the following cheat sheet:

Branch pattern wild card cheat sheet

Glob patterns don't allow any expression to start with a star. Every expression that starts with a star needs to be put in quotes.

feature/*

  • Matches with feature/<any_branch>. 

  • The glob pattern doesn't match the slash (/), so Git branches like feature/<any_branch>/<my_branch> are not matched for feature/*.

feature/bb-123-fix-links

  • If you specify the exact name of a branch, a tag, or a bookmark, the pipeline defined for the specific branch overrides any more generic expressions that would match that branch. 

  • For example, let's say that you specified a pipeline for feature/* and feature/bb-123-fix-links. On a commit to the feature/bb-123-fix-links branch Pipelines will execute steps defined for feature/bb-123-fix-links and will not execute the steps defined in feature/*.

'*'

 

  • Matches all branches, tags, or bookmarks. The star symbol (*) must be in single quotes.

  • This glob pattern doesn't match the slash (/), so Git branches like feature/bb-123-fix-links are not matched for '*'. If you need the slash to match, use '**' instead of '*'.

 

'**'

  • Matches all branches, branches, tags, or bookmarks. For example, it includes branches with the slash (/) like feature/bb-123-fix-links. The ** expression must be in quotes.

'*/feature'

  • This expression requires quotes.

'main' and duplicate branch names

  • Names in quotes are treated the same way as names without quotes. For example, Pipelines sees main and 'main' as the same branch names.  

  • In the situation described above, Pipelines will match only against one name (main or 'main', never both).

  • We recommend that you avoid duplicate names in your bitbucket-pipelines.yml file.

Available actions for notifications

Here's a list of the notifications that are currently available.

Section

Notification type

What it means

Notification actions

Repository

 

Repository notifications will generally include

  • The Bitbucket username of the person who made the change

  • The details of the commit (short SHA and message)

 

 

forked

A fork of the repository was made. Forks are copies of the repository like clones but as a completely separate repository.

 

 

commit comment

Someone commented on a specific commit in the repository.

Reply: Opens a dialog to reply to the pull request comment.

View comment: Opens Bitbucket Cloud to the commit so you can view the full comment.

Pipeline

 

Pipeline notifications will generally contain:

  • The pipeline number (#23)

  • The status of the pipeline

  • The branch being built (only some build systems provide this)

  • commit details (committer, short SHA, and message)

 

 

pipeline succeed

The pipeline successfully completed

 

 

pipeline failed

The pipeline failed

Re-run: Allows you to restart the failed pipeline from Slack.

 

pipeline fixed

A previously failed pipeline completed (or has been rerun) successfully

 

 

deployment succeeded

The deployment succeeded

 

 

deployment stopped

The deployment was stopped, this could be manually stopped or automatically paused due to another deployment already in progress

 

 

deployment failed

The deployment failed or experienced an error condition

 

Build

 

Build notifications will generally contain:

  • The build number (#123)

  • The status of the build (passed or failed)

  • The branch being built (only some build systems provide this)

  • commit details (committer, short SHA, and message)

 

 

build succeeded

The build successfully completed

 

 

build failed

The build failed to complete

 

Branches

 

Branch notifications will generally include

  • The Bitbucket username of the person who pushed a change to the branch or repository.

  • The name of the branch

  • The number of commits added to a branch in a push

  • The details of the commit (short SHA and message)

 

 

branch created

 

A new branch was added to the repository

 

 

 

branch updated

A commit or series of commits were added to the branch

Create pull request: Opens the create pull request page in Bitbucket Cloud for this branch.

 

branch merged

A branch was successfully merged into another branch in the repository

 

 

branch deleted

A branch was deleted from the repository

 

 

force push

You will receive this notification if you're subscribed to branch updated notification.

A change was force pushed outside the normal local to remote ancestry.

Create pull request: Opens the create pull request page in Bitbucket Cloud for this branch.

Pull request

 

Pull request notifications will generally contain:

  • The pull request #

  • The title

  • The author

  • The reviewer(s) assigned to this pull request. We will mark approvals next to the reviewer name.

  • The source branch (the branch with the change)

  • The target branch (the branch which will add the change)

  • The build status (if applicable)

  • The tasks assigned during the review (if applicable)

 

 

pull request created

A new pull request was created

 

 

pull request updated

Any update to the pull request not already covered in a different notification.  Generally whenever someone pushes new changes to the source branch.

 

 

pull request approved

A member of a workspace added an approval to this pull request

Merge: Allows you to merge an approved pull request from Slack.

This action will  appear if you have merge checks enabled.

Currently the merge button will appear whether or not all merge checks have passed. You will get an error if you begin a merge and the merge checks have not passed.

 

pull request unapproved

A member of a workspace has removed approval for this pull request

 

 

pull request merged

The pull request was successfully merged.

 

 

pull request declined

The pull request has been declined and is no longer active

 

 

pull request comment

Someone commented on the pull request

Reply: Opens a dialog to reply to the pull request comment.

View comment: Opens Bitbucket Cloud to the pull request so you can view the full comment.

Tag

 

Tag notifications will generally contain:

  • The Bitbucket username

  • The users @ name

  • The short description of the tag

  • The details of the commit (short SHA and message) if relevant

 

 

tag created

A new tag was added to the repository

 

 

tag updated

A a change was made to an existing tag in the repository

 

 

tag deleted

A tag was removed from the repository

 

Issue tracker

 

Issue notifications will generally contain:

  • The users @ name

  • The issue #

  • The Bitbucket username

  • A short description

  • A few standard fields like: Priority, Type, Assignee

 

 

issue created

A new issue was created

 

 

issue updated

A change was made to one of the issue fields can include updating or adding fields

 

 

issue comment

Someone added a comment to an issue

Reply: Opens a dialog to reply to the issue comment.

View comment: Opens Bitbucket Cloud to that issue so you can view the full comment.

 

transitioned

You will receive this notification if you're subscribed to issue updated notification.

The issue is being assigned to a different member of the workspace

 

Automated responses  

 

Welcome and administrator messages typically contain:

  • A clear response to an action such as the welcome message you receive when you first install the app.

 

 

Welcome (direct to administrator)

The first message the administrator receives when you complete installing Bitbucket Cloud for Slack. Visible as a direct message to the admin who installs the app.

 

 

Welcome (open to the channel)

The first message visible to everyone in the associated workspace.

 

 

New channel response

Automated welcome message when you add the app to a channel. Visible to everyone in that channel.

 

 

New repository response

Automated message response when a new repository is connected to a channel. Visible to everyone in the channel. Only Bitbucket Cloud repository administrators can take action.

Open repository settings: Opens the settings page for the Bitbucket Cloud repository.

 

Unable to find repository

Automated response when someone attempts to connect a repository and we cannot find the repository with a matching URL.

Open Bitbucket: Opens Bitbucket Cloud so the administrator can locate the repository and ensure notifications are configured correctly.

Add Slack messages to pull requests as comments

To make responding to pull requests even easier, Slack includes an Action that allows you to add Slack messages as comments to pull requests.

To add a Slack message to a pull request:

1. Hover over the message and click the ••• icon.
2. Select Attach to pull request.
3. Select the repository with the pull request.
4. Select the pull request in the repository.

The message then appears as a comment on the pull request you selected, showing the author and the user who added the message. To gain more context around the comment, click the message link to take you back to the conversation in Slack.

Slash commands for the Bitbucket Cloud for Slack app

There are several slash commands available for the app.

Command

What it means or does

Required permissions

/bitbucket

Manage your Bitbucket Cloud connections and subscriptions

 

/bitbucket help

List the available commands for this app

 

/bitbucket connect <repository url>

Subscribe to your repository to receive notifications

 

/bitbucket login

Link your Bitbucket Cloud workspace to a Slack workspace.

 

/bitbucket logout

Logout from current account to log in as someone else

 

/bitbucket whoami

Find out what Bitbucket user you are in this workspace

 

/bitbucket feedback

Leave us your feedback about the app

 

/bitbucket list

Get a list of all repositories you connected to this workspace

 

Still need help?

The Atlassian Community is here for you.