Skip to content

Add Bitbucket support #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- [Sourcebot EE] Added search contexts, user-defined groupings of repositories that help focus searches on specific areas of a codebase. [#273](https://github.com/sourcebot-dev/sourcebot/pull/273)
- Added support for Bitbucket Cloud and Bitbucket Data Center connections. [#275](https://github.com/sourcebot-dev/sourcebot/pull/275)


## [3.0.4] - 2025-04-12
Expand Down
2 changes: 2 additions & 0 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"docs/connections/overview",
"docs/connections/github",
"docs/connections/gitlab",
"docs/connections/bitbucket-cloud",
"docs/connections/bitbucket-data-center",
"docs/connections/gitea",
"docs/connections/gerrit",
"docs/connections/request-new"
Expand Down
201 changes: 201 additions & 0 deletions docs/docs/connections/bitbucket-cloud.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
---
title: Linking code from Bitbucket Cloud
sidebarTitle: Bitbucket Cloud
---

import BitbucketToken from '/snippets/bitbucket-token.mdx';
import BitbucketAppPassword from '/snippets/bitbucket-app-password.mdx';

## Examples

<AccordionGroup>
<Accordion title="Sync individual repos">
```json
{
"type": "bitbucket",
"deploymentType": "cloud",
"repos": [
"myWorkspace/myRepo"
]
}
```
</Accordion>
<Accordion title="Sync all repos in a workspace">
```json
{
"type": "bitbucket",
"deploymentType": "cloud",
"workspaces": [
"myWorkspace"
]
}
```
</Accordion>
<Accordion title="Sync all repos in a project">
```json
{
"type": "bitbucket",
"deploymentType": "cloud",
"projects": [
"myProject"
]
}
```
</Accordion>
<Accordion title="Exclude repos from syncing">
```json
{
"type": "bitbucket",
"deploymentType": "cloud",
// Include all repos in my-workspace...
"workspaces": [
"myWorkspace"
],
// ...except:
"exclude": {
// repos that are archived
"archived": true,
// repos that are forks
"forks": true,
// repos that match these glob patterns
"repos": [
"myWorkspace/repo1",
"myWorkspace2/*"
]
}
}
```
</Accordion>
</AccordionGroup>

## Authenticating with Bitbucket Cloud

In order to index private repositories, you'll need to provide authentication credentials. You can do this using an `App Password` or an `Access Token`

<Tabs>
<Tab title="App Password">
Navigate to the [app password creation page](https://bitbucket.org/account/settings/app-passwords/) and create an app password. Ensure that it has the proper permissions for the scope
of info you want to fetch (i.e. workspace, project, and/or repo level)
![Bitbucket App Password Permissions](/images/bitbucket_app_password_perms.png)

Next, provide your username + app password pair to Sourcebot:

<BitbucketAppPassword />
</Tab>
<Tab title="Access Token">
Create an access token for the desired scope (repo, project, or workspace). Visit the official [Bitbucket Cloud docs](https://support.atlassian.com/bitbucket-cloud/docs/access-tokens/)
for more info.

Next, provide the access token to Sourcebot:

<BitbucketToken />
</Tab>
</Tabs>


## Schema reference

<Accordion title="Reference">
[schemas/v3/bitbucket.json](https://github.com/sourcebot-dev/sourcebot/blob/main/schemas/v3/bitbucket.json)

```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"title": "BitbucketConnectionConfig",
"properties": {
"type": {
"const": "bitbucket",
"description": "Bitbucket configuration"
},
"user": {
"type": "string",
"description": "The username to use for authentication. Only needed if token is an app password."
},
"token": {
"$ref": "./shared.json#/definitions/Token",
"description": "An authentication token.",
"examples": [
{
"secret": "SECRET_KEY"
}
]
},
"url": {
"type": "string",
"format": "url",
"default": "https://api.bitbucket.org/2.0",
"description": "Bitbucket URL",
"examples": [
"https://bitbucket.example.com"
],
"pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$"
},
"deploymentType": {
"type": "string",
"enum": ["cloud", "server"],
"default": "cloud",
"description": "The type of Bitbucket deployment"
},
"workspaces": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of workspaces to sync. Ignored if deploymentType is server."
},
"projects": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of projects to sync"
},
"repos": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of repos to sync"
},
"exclude": {
"type": "object",
"properties": {
"archived": {
"type": "boolean",
"default": false,
"description": "Exclude archived repositories from syncing."
},
"forks": {
"type": "boolean",
"default": false,
"description": "Exclude forked repositories from syncing."
},
"repos": {
"type": "array",
"items": {
"type": "string"
},
"examples": [
[
"cloud_workspace/repo1",
"server_project/repo2"
]
],
"description": "List of specific repos to exclude from syncing."
}
},
"additionalProperties": false
},
"revisions": {
"$ref": "./shared.json#/definitions/GitRevisions"
}
},
"required": [
"type"
],
"additionalProperties": false
}
```

</Accordion>
Loading