| title | Linking code from Bitbucket Data Center |
|---|---|
| sidebarTitle | Bitbucket Data Center |
| icon | Bitbucket |
import BitbucketSchema from '/snippets/schemas/v3/bitbucket.schema.mdx'
Looking for docs on Bitbucket Cloud? See [this doc](/docs/connections/bitbucket-cloud).If you're not familiar with Sourcebot connections, please read that overview first.
```json { "type": "bitbucket", "deploymentType": "server", "url": "https://mybitbucketdeployment.com", "repos": [ "myProject/myRepo" ] } ``` ```json { "type": "bitbucket", "deploymentType": "server", "url": "https://mybitbucketdeployment.com", "projects": [ "myProject" ] } ``` Requires a `token` to be set in order to access private repositories. ```json { "type": "bitbucket", "deploymentType": "server", "url": "https://mybitbucketdeployment.com", // Index all repos visible to the provided token "all": true } ``` ```json { "type": "bitbucket", "deploymentType": "server", "url": "https://mybitbucketdeployment.com", // Include all repos in myProject... "projects": [ "myProject" ], // ...except: "exclude": { // repos that are archived "archived": true, // repos that are forks "forks": true, // repos that match these glob patterns "repos": [ "myProject/repo1", "myProject2/*" ] } } ```In order to index private repositories, you'll need to provide a HTTP Access Token. Tokens can be scoped to a user account, a project, or an individual repository. Only repositories visible to the token will be able to be indexed by Sourcebot.
If [permission syncing](/docs/features/permission-syncing#bitbucket-data-center) is enabled, the token must have **Repository Admin** permissions so Sourcebot can read repository-level user permissions. User account tokens grant access to all repositories the user can access. Because these are tied to a specific user account, you must also set the `user` field to that user's username. 1. In Bitbucket Data Center, navigate to your profile → **Manage account** → **HTTP access tokens** and click **Create token**. Give it a name and grant it **Project read** and **Repository read** permissions.
2. Add the `user` (your Bitbucket username) and `token` properties to your connection config:
```json
{
"type": "bitbucket",
"deploymentType": "server",
"url": "https://mybitbucketdeployment.com",
"user": "myusername",
"token": {
// note: this env var can be named anything. It
// doesn't need to be `BITBUCKET_TOKEN`.
"env": "BITBUCKET_TOKEN"
}
// .. rest of config ..
}
```
3. Pass this environment variable each time you run Sourcebot:
```bash
docker run \
-e BITBUCKET_TOKEN=<ACCESS_TOKEN> \
/* additional args */ \
ghcr.io/sourcebot-dev/sourcebot:latest
```
</Tab>
<Tab title="Project / repository token">
Project and repository tokens are scoped to a specific project or repository.
1. In Bitbucket Data Center, navigate to the project or repository → **Settings** → **HTTP access tokens** and click **Create token**. Give it a name and grant it **Repository read** and **Project read** permissions.
2. Add the `token` property to your connection config:
```json
{
"type": "bitbucket",
"deploymentType": "server",
"url": "https://mybitbucketdeployment.com",
"token": {
// note: this env var can be named anything. It
// doesn't need to be `BITBUCKET_TOKEN`.
"env": "BITBUCKET_TOKEN"
}
// .. rest of config ..
}
```
3. Pass this environment variable each time you run Sourcebot:
```bash
docker run \
-e BITBUCKET_TOKEN=<ACCESS_TOKEN> \
/* additional args */ \
ghcr.io/sourcebot-dev/sourcebot:latest
```
</Tab>
If you're seeing errors like TypeError: fetch failed when fetching repo info, it may be that Sourcebot is refusing to connect to your self-hosted Bitbucket instance due to unrecognized SSL certs. Try setting the NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable or providing Sourcebot your certs through the NODE_EXTRA_CA_CERTS environment variable.