Bitbucket To Slack

The following page will walk you through how to integrate BitBucket into a Slack channel.

Start by heading over to the channel on Slack that you'd like these updates to come through in and invite the Bitbucket bot by doing @Bitbucket Cloud and clicking on "Invite Them".

Invite Bitbucket

After clicking "Invite Them", you will see some example of updates in the chat log, along with the following:

"Please run /bitbucket connect <your-repository-url> command to connect your repository. You can connect as many repositories as you need."

Now, we'll select which repo you would like to receive Slack notifications for.

Click on the "Repositories" icon on the left hand side of the BitBucket Homepage (you may have to sign in first) to bring up the list of repos.
You can either search the list of repos shown, or use the search bar to find your specific repo.

For this example, I have made one called "Example for Webhook Handbook Page".

Example Repo

Clicking on the name of the repo will take you through to it.

Once inside the repo, copy the URL for this page, and paste it into the command you got earlier. Remember to remove the "< >" on each end of the URL as well.

It should look something like the following: /bitbucket connect https://bitbucket.org/edmondscommerce/example-for-webhook-handbook-page/src/master/

You'll then see another message asking you to link your Bitbucket Cloud account to your Slack account.

Link Accounts

Clicking "Link Account" will open up a webpage asking you to authorize the link.
Click "Authorize" if you're happy to continue.

Authorize Account Link

The webpage will then redirect to show that that was successful.
You'll also see a message come through in the Slack channel you've been working in confirming this as well.

Chrome Confirmation

Slack Confirmation

Now, head back to the repository we took the URL for and click on "Settings" on the left hand side of the page.

Settings

Scroll to the bottom of the page and click on "Settings" under "Chat Notifications".

Chat Notification Settings

This will take you to a page displaying your "Subscriptions" to different chat apps.
Click the blue "Add Subscription" button at the top of the screen.

Add Subscription

This will bring up the following window, shown down below, where we will choose which channel we want these updates to come through in. Make sure that it is set to our "Edmonds Commerce" workspace and select the channel you'd like from the dropdown list.

Workspace and Channel

When ready, click "Add".

You will receive a notification in the Slack channel if that has been added successfully.

Subscribed to Channel

In Chrome, you will see a list of different notifications that will be sent through to the Slack channel, depending on what happens with the repo.

Repo Notifications

These should be left as they are, so all that's left to do now is check that these will display in the channel.

Headback to the main page of the repository by clicking "Source" on the left.

Source

Now, click on any file that you're happy to edit in the repo. I've chosen the "README.md" file.

Read me

Now, click "Edit" on the right to begin editing the file.

Edit

Alter the file by typing into the box and then click "Commit" in the bottom right.

Edit and Commit

Before the commit goes through, you'll be asked to provide a commit message describing what you did.
Click on "Commit" when you're happy with your message.

Commit Message

Now if we head over to the Slack channel, we can see that the integration has indeed worked and notifications for the repo are coming through to Slack.

Commit Notification

This also works when working with the repo in the terminal. This isn't exclusive to doing this on the website.