You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(bitbucket): add gitUser field to support API token auth on Bitbucket Cloud (#918)
* feat(bitbucket): add gitUser field to support API token auth on Bitbucket Cloud
BitBucket Cloud API tokens require different usernames for the REST API
(email address) and git clone (Atlassian username). Add an optional
`gitUser` field to the BitBucket connection config that, when set, is
used for git clone credentials instead of `user`.
Fixes#892
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: update CHANGELOG for #918
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: delete unused Bitbucket snippet files
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
16
16
- Skip calling `getCommitHashForRefName` for empty repositories to avoid noisy debug log output. [#914](https://github.com/sourcebot-dev/sourcebot/pull/914)
17
17
- Fixed "Open in GitLab" links having a double slash when the GitLab host URL is configured with a trailing slash. [#915](https://github.com/sourcebot-dev/sourcebot/pull/915)
18
18
19
+
### Added
20
+
- Added optional `gitUser` field to the Bitbucket connection config to support Bitbucket Cloud API tokens, which require an email address for the REST API but an Atlassian username for git clone. [#918](https://github.com/sourcebot-dev/sourcebot/pull/918)
@@ -78,25 +76,107 @@ If you're not familiar with Sourcebot [connections](/docs/connections/overview),
78
76
79
77
## Authenticating with Bitbucket Cloud
80
78
81
-
In order to index private repositories, you'll need to provide authentication credentials via a [token](/docs/configuration/config-file#tokens). You can do this using an `App Password` or an `Access Token`
79
+
In order to index private repositories, you'll need to provide authentication credentials via a [token](/docs/configuration/config-file#tokens). You can do this using an `API Token`, `Access Token`, or `App Password`.
82
80
83
81
<Tabs>
84
-
<Tabtitle="App Password">
85
-
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
86
-
of info you want to fetch (i.e. workspace, project, and/or repo level)
Next, provide your username + app password pair to Sourcebot:
90
-
91
-
<BitbucketAppPassword />
82
+
<Tabtitle="API Token">
83
+
1. Navigate to [Personal Settings → API tokens](https://id.atlassian.com/manage-profile/security/api-tokens) and click **Create API token with scopes**. Give the token a name and set an expiry date.
84
+
85
+
2. Select **Bitbucket** as the app.
86
+
87
+
3. Select the following scopes:
88
+
-`read:repository:bitbucket` — View your repositories
89
+
-`read:workspace:bitbucket` — View your workspaces
90
+
91
+
4. Click **Create token** and copy the token value.
92
+
93
+
5. Add the `user` (your account email), `gitUser` (your Bitbucket username), and `token` to your connection config. [Learn why both are needed](https://support.atlassian.com/bitbucket-cloud/docs/using-api-tokens/)
94
+
95
+
```json
96
+
{
97
+
"type": "bitbucket",
98
+
"deploymentType": "cloud",
99
+
"user": "you@example.com",
100
+
"gitUser": "myusername",
101
+
"token": {
102
+
// note: this env var can be named anything. It
103
+
// doesn't need to be `BITBUCKET_TOKEN`.
104
+
"env": "BITBUCKET_TOKEN"
105
+
}
106
+
// .. rest of config ..
107
+
}
108
+
```
109
+
110
+
6. Pass this environment variable each time you run Sourcebot:
111
+
112
+
```bash
113
+
docker run \
114
+
-e BITBUCKET_TOKEN=<API_TOKEN> \
115
+
/* additional args */ \
116
+
ghcr.io/sourcebot-dev/sourcebot:latest
117
+
```
92
118
</Tab>
93
119
<Tabtitle="Access Token">
94
120
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/)
95
121
for more info.
96
122
97
-
Next, provide the access token to Sourcebot:
123
+
1. Add the `token` property to your connection config:
124
+
125
+
```json
126
+
{
127
+
"type": "bitbucket",
128
+
"deploymentType": "cloud",
129
+
"token": {
130
+
// note: this env var can be named anything. It
131
+
// doesn't need to be `BITBUCKET_TOKEN`.
132
+
"env": "BITBUCKET_TOKEN"
133
+
}
134
+
// .. rest of config ..
135
+
}
136
+
```
137
+
138
+
2. Pass this environment variable each time you run Sourcebot:
139
+
140
+
```bash
141
+
docker run \
142
+
-e BITBUCKET_TOKEN=<ACCESS_TOKEN> \
143
+
/* additional args */ \
144
+
ghcr.io/sourcebot-dev/sourcebot:latest
145
+
```
146
+
</Tab>
147
+
<Tabtitle="App Password">
148
+
<Warning>
149
+
App Passwords are deprecated. Atlassian recommends migrating to API tokens. [Learn more](https://www.atlassian.com/blog/bitbucket/bitbucket-cloud-transitions-to-api-tokens-enhancing-security-with-app-password-deprecation)
150
+
</Warning>
151
+
152
+
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
153
+
of info you want to fetch (i.e. workspace, project, and/or repo level)
@@ -75,9 +73,30 @@ In order to index private repositories, you'll need to provide an access token t
75
73
Create an access token for the desired scope (repo, project, or workspace). Visit the official [Bitbucket Data Center docs](https://confluence.atlassian.com/bitbucketserver/http-access-tokens-939515499.html)
76
74
for more info.
77
75
78
-
Next, provide the access token to Sourcebot:
79
-
80
-
<BitbucketToken />
76
+
1. Add the `token` property to your connection config:
77
+
78
+
```json
79
+
{
80
+
"type": "bitbucket",
81
+
"deploymentType": "server",
82
+
"url": "https://mybitbucketdeployment.com",
83
+
"token": {
84
+
// note: this env var can be named anything. It
85
+
// doesn't need to be `BITBUCKET_TOKEN`.
86
+
"env": "BITBUCKET_TOKEN"
87
+
}
88
+
// .. rest of config ..
89
+
}
90
+
```
91
+
92
+
2. Pass this environment variable each time you run Sourcebot:
93
+
94
+
```bash
95
+
docker run \
96
+
-e BITBUCKET_TOKEN=<ACCESS_TOKEN> \
97
+
/* additional args */ \
98
+
ghcr.io/sourcebot-dev/sourcebot:latest
99
+
```
81
100
82
101
## Troubleshooting
83
102
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.
Copy file name to clipboardExpand all lines: docs/snippets/schemas/v3/bitbucket.schema.mdx
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,11 @@
11
11
},
12
12
"user": {
13
13
"type": "string",
14
-
"description": "The username to use for authentication. Only needed if token is an app password."
14
+
"description": "The username to use for API authentication. For app passwords, this is your Bitbucket username. For API tokens, this is your Bitbucket account email address."
15
+
},
16
+
"gitUser": {
17
+
"type": "string",
18
+
"description": "The username to use for git clone authentication over HTTPS. If not set, falls back to 'user'. For API tokens, this is your Bitbucket username"
Copy file name to clipboardExpand all lines: docs/snippets/schemas/v3/connection.schema.mdx
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -688,7 +688,11 @@
688
688
},
689
689
"user": {
690
690
"type": "string",
691
-
"description": "The username to use for authentication. Only needed if token is an app password."
691
+
"description": "The username to use for API authentication. For app passwords, this is your Bitbucket username. For API tokens, this is your Bitbucket account email address."
692
+
},
693
+
"gitUser": {
694
+
"type": "string",
695
+
"description": "The username to use for git clone authentication over HTTPS. If not set, falls back to 'user'. For API tokens, this is your Bitbucket username"
Copy file name to clipboardExpand all lines: docs/snippets/schemas/v3/index.schema.mdx
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1103,7 +1103,11 @@
1103
1103
},
1104
1104
"user": {
1105
1105
"type": "string",
1106
-
"description": "The username to use for authentication. Only needed if token is an app password."
1106
+
"description": "The username to use for API authentication. For app passwords, this is your Bitbucket username. For API tokens, this is your Bitbucket account email address."
1107
+
},
1108
+
"gitUser": {
1109
+
"type": "string",
1110
+
"description": "The username to use for git clone authentication over HTTPS. If not set, falls back to 'user'. For API tokens, this is your Bitbucket username"
Copy file name to clipboardExpand all lines: packages/schemas/src/v3/bitbucket.schema.ts
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,11 @@ const schema = {
10
10
},
11
11
"user": {
12
12
"type": "string",
13
-
"description": "The username to use for authentication. Only needed if token is an app password."
13
+
"description": "The username to use for API authentication. For app passwords, this is your Bitbucket username. For API tokens, this is your Bitbucket account email address."
14
+
},
15
+
"gitUser": {
16
+
"type": "string",
17
+
"description": "The username to use for git clone authentication over HTTPS. If not set, falls back to 'user'. For API tokens, this is your Bitbucket username"
0 commit comments