# Bitbucket Datacenter/Server

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

## 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 and click the _Set up_ button next to the Bitbucket Data Center integration:

![](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-MiQe7QZyaYPwrS9rag1%2F-MiQeZBq7JgMMHy1S-Yl%2Fimage.png?alt=media\&token=821f12ca-59b5-4bba-b3e4-59a861d5ea14)

This should open a form like this one:

![](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-MiQe7QZyaYPwrS9rag1%2F-MiQeetB7pkTan-TGTF2%2Fimage.png?alt=media\&token=9a51a4b7-4167-4aad-85f6-7588df420005)

Now you'll have to fill in the API host URL, which is the URL on which Spacelift will access the Bitbucket server. This may be a URL which uses [VCS Agent Pools](../../concepts/vcs-agent-pools), or a normal URL, if your Bitbucket instance is publicly available.

The user facing host URL is the address on which users of you Bitbucket instance access it. This could be an internal address inside of your company network, but could also by a public address if your Bitbucket instance is publicly available.

In order to get the access token you'll need to go on your Bitbucket instance into **Manage account -> Personal access tokens -> create**. There, you will need to give your new access token a name and give it write access to repositories:

![Personal token creation](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-M_eCs0wyl3FxJuYXxsm%2F-M_eErrGT0MIf2ZYfo-a%2Fimage.png?alt=media\&token=4f20f8b9-c919-48d1-a6c4-70664f13495e)

This will give you an access token which you can put into the **Access token** field in the integration configuration.\


![Created personal token](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-M_eCs0wyl3FxJuYXxsm%2F-M_eFBKHS08V7Dmz3UTx%2Fimage.png?alt=media\&token=fb0bf72b-faa7-4d70-afe1-8eb2a3dedb2e)

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

![](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-MiQe7QZyaYPwrS9rag1%2F-MiQezimluPwTYiQVCvU%2Fimage.png?alt=media\&token=cd661462-af12-4c20-ad0a-6e42a1c2bba7)

After saving, you'll receive your webhook secret and endpoint:

![](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-MiQe7QZyaYPwrS9rag1%2F-MiQf7SkCa5bkEcMxRXj%2Fimage.png?alt=media\&token=3601cf3c-c5a8-4edb-91c6-a28156658423)

For each repository you want to use with Spacelift, you need to go into its **Repository settings -> Webhooks -> Create webhook**, and configure the webhooks accordingly, by activating Push and Pull Request Opened events.

![Configuring Webhooks](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LshwwDZmA4HXN0k9e8O%2Fuploads%2FYfRhVRwStRFwz8WMVU3l%2FScreenshot%202022-02-04%20at%2012.02.27.png?alt=media\&token=5de8e52f-fc71-4b40-8955-990c54047c1d)

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

![Creating a Stack with the Bitbucket Datacenter integration](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-M_eCs0wyl3FxJuYXxsm%2F-M_eGoMKZA_9biHJxaga%2Fimage.png?alt=media\&token=111b5b71-9976-470b-993d-3d16eaa6e69e)
