# Bitbucket Cloud

In addition to our out-of-the-box [integration with GitHub](github) , Spacelift supports using Bitbucket Cloud as the source of code for your [stacks](../../concepts/stack) and [modules](../../vendors/terraform/module-registry).&#x20;

## Setting up the integration

In order to set up the integration from the Spacelift side, please navigate to the VCS providers section of the admin Settings page, find the Bitbucket Cloud integration and click the _Set up_ button:

![VCS providers page](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-Mbq6DPrUeFojZMr3tHJ%2F-MbqEfMAa3NiSyf0l03H%2FScreenshot%20from%202021-06-10%2016-05-39.png?alt=media\&token=77ff0664-d71b-477b-b331-57001e0fa6af)

This should open a form like this one:

![Bitbucket Cloud setup form](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-Mbq6DPrUeFojZMr3tHJ%2F-MbqFWXcZPgLaVI51ZYp%2FScreenshot%20from%202021-06-10%2016-09-36.png?alt=media\&token=04e5c0fe-bb23-4c15-ade7-315be4474dac)

Now you'll have to fill in the Username, which is a username of your Bitbucket Cloud account.

In order to get the [App password](https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/) you'll need to go to the Bitbucket Cloud site and navigate to **Personal settings** -> **App passwords** (it's under Access management) -> **Create app password**. There, you will need to give your new app password a label and give it read access to repositories and pull requests:

![App password creation](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-Mbq6DPrUeFojZMr3tHJ%2F-MbqLcnzKMIJg2y3cfnN%2FScreenshot%20from%202021-06-10%2016-16-53.png?alt=media\&token=61748251-0537-4f5a-909d-4f60f5d054c0)

This will give you an app password token which you can put into the **App Password** field in the integration configuration.

![Created new app password](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-Mbq6DPrUeFojZMr3tHJ%2F-MbqMIlLmtYuDp2JHnAk%2FScreenshot%20from%202021-06-10%2016-39-03.png?alt=media\&token=199acc9c-6ef2-4eb4-a07b-861a5bec6d63)

After doing all this you should have all fields filled in.

![Filled in Bitbucket Cloud integration form](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-MbuFC4nyWxos6sEg1gD%2F-MbuG8Q7gfJuRq9f7J_V%2FScreenshot%20from%202021-06-11%2010-50-38.png?alt=media\&token=92700dcf-7359-479e-824c-2c874eee3029)

After saving, you'll receive your webhook endpoint:

![Configured integration](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-Mbv6SIsulf599hsAilc%2F-Mbv7WV8_Xgh_kI5YkYH%2FScreenshot%20from%202021-06-11%2014-52-40.png?alt=media\&token=dd31dde1-e4e8-425d-a64b-db9a3b59ede1)

For each repository you want to use with Spacelift, you now have to go into its **Repository settings -> Webhooks -> Add webhook**, and configure the webhook accordingly, by activating Push, Pull Request Created, Pull Request Updated and Pull Request Merged events.

![Webhooks configuration](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LshwwDZmA4HXN0k9e8O%2Fuploads%2Fze40Pq7loBHi379cgxVK%2FScreenshot%202022-02-16%20at%2014.57.25.png?alt=media\&token=24939c42-4ad5-4382-a4c6-efad0903c931)

The last step is to install the **Pull Request Commit Links** app to be able to use [this](https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/commit/%7Bcommit%7D/pullrequests) API. This is done automatically when you go to the commit's details and then click "Pull requests" link.

![Commit's details](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-McDyhYyRloAz2NgrEI7%2F-McDylTaEyxX4rAW-5ec%2FScreenshot%20from%202021-06-15%2011-19-56.png?alt=media\&token=3d0adc0a-158c-4aef-a3e3-c50e28857c9a)

When creating a Stack, you will now be able to choose the Bitbucket Cloud provider and a repository inside of it:

![Stack creation form](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-Mbv6SIsulf599hsAilc%2F-Mbv9wZC5Y6zZuA8f_GC%2FScreenshot%20from%202021-06-11%2015-03-21.png?alt=media\&token=0b71a9c6-2930-445c-8d81-58f1e45eddac)

## Unlinking the Integration

If you no-longer need the integration, you can remove it via the _Unlink_ button on the VCS settings page.

![VCS providers page](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-Mc8HRNoCzYNBODbJ_U5%2F-Mc8I0BUzBaOoCjlJ1vP%2FScreenshot%20from%202021-06-14%2008-53-09.png?alt=media\&token=09c5f236-b2ae-4910-87c7-6349af0f17b1)

Please also remember to remove any Spacelift webhooks from your repositories.
