From bcbc11fb51fc101be2ffddf7e8ba85b769b1f8ec Mon Sep 17 00:00:00 2001 From: Christian Svedin Date: Tue, 24 Feb 2026 09:12:17 +0100 Subject: [PATCH 1/5] Update bitbucket json schema --- schemas/v3/bitbucket.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/schemas/v3/bitbucket.json b/schemas/v3/bitbucket.json index 4bac5e1b2..d8e707a70 100644 --- a/schemas/v3/bitbucket.json +++ b/schemas/v3/bitbucket.json @@ -31,6 +31,11 @@ "default": "cloud", "description": "The type of Bitbucket deployment" }, + "all": { + "type": "boolean", + "default": false, + "description": "Sync all repositories visible to the provided `token` (if any) in the Bitbucket Server instance. This option is ignored if `deploymentType` is `cloud`." + }, "workspaces": { "type": "array", "items": { From 3bf9d9d7fdbcefbe9c748404f697b64bb0f3cc9e Mon Sep 17 00:00:00 2001 From: Christian Svedin Date: Tue, 24 Feb 2026 09:29:17 +0100 Subject: [PATCH 2/5] Add generated schema files --- docs/snippets/schemas/v3/bitbucket.schema.mdx | 5 +++++ docs/snippets/schemas/v3/connection.schema.mdx | 5 +++++ docs/snippets/schemas/v3/index.schema.mdx | 5 +++++ packages/schemas/src/v3/bitbucket.schema.ts | 5 +++++ packages/schemas/src/v3/bitbucket.type.ts | 4 ++++ packages/schemas/src/v3/connection.schema.ts | 5 +++++ packages/schemas/src/v3/connection.type.ts | 4 ++++ packages/schemas/src/v3/index.schema.ts | 5 +++++ packages/schemas/src/v3/index.type.ts | 4 ++++ 9 files changed, 42 insertions(+) diff --git a/docs/snippets/schemas/v3/bitbucket.schema.mdx b/docs/snippets/schemas/v3/bitbucket.schema.mdx index d39ca8bef..401842b33 100644 --- a/docs/snippets/schemas/v3/bitbucket.schema.mdx +++ b/docs/snippets/schemas/v3/bitbucket.schema.mdx @@ -63,6 +63,11 @@ "default": "cloud", "description": "The type of Bitbucket deployment" }, + "all": { + "type": "boolean", + "default": false, + "description": "Sync all repositories visible to the provided `token` (if any) in the Bitbucket Server instance. This option is ignored if `deploymentType` is `cloud`." + }, "workspaces": { "type": "array", "items": { diff --git a/docs/snippets/schemas/v3/connection.schema.mdx b/docs/snippets/schemas/v3/connection.schema.mdx index 7070a1a9e..d57e58b33 100644 --- a/docs/snippets/schemas/v3/connection.schema.mdx +++ b/docs/snippets/schemas/v3/connection.schema.mdx @@ -740,6 +740,11 @@ "default": "cloud", "description": "The type of Bitbucket deployment" }, + "all": { + "type": "boolean", + "default": false, + "description": "Sync all repositories visible to the provided `token` (if any) in the Bitbucket Server instance. This option is ignored if `deploymentType` is `cloud`." + }, "workspaces": { "type": "array", "items": { diff --git a/docs/snippets/schemas/v3/index.schema.mdx b/docs/snippets/schemas/v3/index.schema.mdx index 5c575bc3c..0a9c181ba 100644 --- a/docs/snippets/schemas/v3/index.schema.mdx +++ b/docs/snippets/schemas/v3/index.schema.mdx @@ -1155,6 +1155,11 @@ "default": "cloud", "description": "The type of Bitbucket deployment" }, + "all": { + "type": "boolean", + "default": false, + "description": "Sync all repositories visible to the provided `token` (if any) in the Bitbucket Server instance. This option is ignored if `deploymentType` is `cloud`." + }, "workspaces": { "type": "array", "items": { diff --git a/packages/schemas/src/v3/bitbucket.schema.ts b/packages/schemas/src/v3/bitbucket.schema.ts index 3e75400ef..42dd0ec8b 100644 --- a/packages/schemas/src/v3/bitbucket.schema.ts +++ b/packages/schemas/src/v3/bitbucket.schema.ts @@ -62,6 +62,11 @@ const schema = { "default": "cloud", "description": "The type of Bitbucket deployment" }, + "all": { + "type": "boolean", + "default": false, + "description": "Sync all repositories visible to the provided `token` (if any) in the Bitbucket Server instance. This option is ignored if `deploymentType` is `cloud`." + }, "workspaces": { "type": "array", "items": { diff --git a/packages/schemas/src/v3/bitbucket.type.ts b/packages/schemas/src/v3/bitbucket.type.ts index d03f89668..19b59dd66 100644 --- a/packages/schemas/src/v3/bitbucket.type.ts +++ b/packages/schemas/src/v3/bitbucket.type.ts @@ -33,6 +33,10 @@ export interface BitbucketConnectionConfig { * The type of Bitbucket deployment */ deploymentType?: "cloud" | "server"; + /** + * Sync all repositories visible to the provided `token` (if any) in the Bitbucket Server instance. This option is ignored if `deploymentType` is `cloud`. + */ + all?: boolean; /** * List of workspaces to sync. Ignored if deploymentType is server. */ diff --git a/packages/schemas/src/v3/connection.schema.ts b/packages/schemas/src/v3/connection.schema.ts index 51f6bcda7..db1044793 100644 --- a/packages/schemas/src/v3/connection.schema.ts +++ b/packages/schemas/src/v3/connection.schema.ts @@ -739,6 +739,11 @@ const schema = { "default": "cloud", "description": "The type of Bitbucket deployment" }, + "all": { + "type": "boolean", + "default": false, + "description": "Sync all repositories visible to the provided `token` (if any) in the Bitbucket Server instance. This option is ignored if `deploymentType` is `cloud`." + }, "workspaces": { "type": "array", "items": { diff --git a/packages/schemas/src/v3/connection.type.ts b/packages/schemas/src/v3/connection.type.ts index 3bd5feb45..ec2caad8e 100644 --- a/packages/schemas/src/v3/connection.type.ts +++ b/packages/schemas/src/v3/connection.type.ts @@ -284,6 +284,10 @@ export interface BitbucketConnectionConfig { * The type of Bitbucket deployment */ deploymentType?: "cloud" | "server"; + /** + * Sync all repositories visible to the provided `token` (if any) in the Bitbucket Server instance. This option is ignored if `deploymentType` is `cloud`. + */ + all?: boolean; /** * List of workspaces to sync. Ignored if deploymentType is server. */ diff --git a/packages/schemas/src/v3/index.schema.ts b/packages/schemas/src/v3/index.schema.ts index d3482891a..77de46c13 100644 --- a/packages/schemas/src/v3/index.schema.ts +++ b/packages/schemas/src/v3/index.schema.ts @@ -1154,6 +1154,11 @@ const schema = { "default": "cloud", "description": "The type of Bitbucket deployment" }, + "all": { + "type": "boolean", + "default": false, + "description": "Sync all repositories visible to the provided `token` (if any) in the Bitbucket Server instance. This option is ignored if `deploymentType` is `cloud`." + }, "workspaces": { "type": "array", "items": { diff --git a/packages/schemas/src/v3/index.type.ts b/packages/schemas/src/v3/index.type.ts index a3342dd18..9a280fbd4 100644 --- a/packages/schemas/src/v3/index.type.ts +++ b/packages/schemas/src/v3/index.type.ts @@ -482,6 +482,10 @@ export interface BitbucketConnectionConfig { * The type of Bitbucket deployment */ deploymentType?: "cloud" | "server"; + /** + * Sync all repositories visible to the provided `token` (if any) in the Bitbucket Server instance. This option is ignored if `deploymentType` is `cloud`. + */ + all?: boolean; /** * List of workspaces to sync. Ignored if deploymentType is server. */ From bd38a319e59c4099cd4c14928c7e0c317bf18341 Mon Sep 17 00:00:00 2001 From: Christian Svedin Date: Tue, 24 Feb 2026 10:54:57 +0100 Subject: [PATCH 3/5] Implement getting all repos --- packages/backend/src/bitbucket.ts | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/packages/backend/src/bitbucket.ts b/packages/backend/src/bitbucket.ts index ef0b547e6..e14a2f4cd 100644 --- a/packages/backend/src/bitbucket.ts +++ b/packages/backend/src/bitbucket.ts @@ -74,6 +74,18 @@ export const getBitbucketReposFromConfig = async (config: BitbucketConnectionCon let allRepos: BitbucketRepository[] = []; let allWarnings: string[] = []; + if (config.all === true) { + if (client.deploymentType === BITBUCKET_SERVER) { + const { repos, warnings } = await serverGetAllRepos(client); + allRepos = allRepos.concat(repos); + allWarnings = allWarnings.concat(warnings); + } else { + const warning = `Ignoring option all:true in config: not supported for Bitbucket Cloud`; + logger.warn(warning); + allWarnings = allWarnings.concat(warning); + } + } + if (config.workspaces) { const { repos, warnings } = await client.getReposForWorkspace(client, config.workspaces); allRepos = allRepos.concat(repos); @@ -553,6 +565,26 @@ async function serverGetRepos(client: BitbucketClient, repoList: string[]): Prom }; } +async function serverGetAllRepos(client: BitbucketClient): Promise<{repos: ServerRepository[], warnings: string[]}> { + logger.debug(`Fetching all repos from Bitbucket Server...`); + const path = `/rest/api/1.0/repos` as ServerGetRequestPath; + const { durationMs, data } = await measure(async () => { + const fetchFn = () => getPaginatedServer(path, async (url, start) => { + const response = await client.apiClient.GET(url, { + params: { query: { start } } + }); + const { data, error } = response; + if (error) { + throw new Error(`Failed to fetch all repos: ${JSON.stringify(error)}`); + } + return data; + }); + return fetchWithRetry(fetchFn, `all repos`, logger); + }); + logger.debug(`Found ${data.length} total repos in ${durationMs}ms.`); + return { repos: data, warnings: [] }; +} + export function serverShouldExcludeRepo(repo: BitbucketRepository, config: BitbucketConnectionConfig): boolean { const serverRepo = repo as ServerRepository; From a467bb9536303e30952beb100a70959591913e5d Mon Sep 17 00:00:00 2001 From: Christian Svedin Date: Tue, 24 Feb 2026 11:02:47 +0100 Subject: [PATCH 4/5] Add documentation --- docs/docs/connections/bitbucket-data-center.mdx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/docs/connections/bitbucket-data-center.mdx b/docs/docs/connections/bitbucket-data-center.mdx index f88e98a15..6ffa957d9 100644 --- a/docs/docs/connections/bitbucket-data-center.mdx +++ b/docs/docs/connections/bitbucket-data-center.mdx @@ -41,6 +41,18 @@ If you're not familiar with Sourcebot [connections](/docs/connections/overview), } ``` + + 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 { From aaf18a2abbb81367f9132955b8033ae63bbd0851 Mon Sep 17 00:00:00 2001 From: Christian Svedin Date: Wed, 25 Feb 2026 11:39:51 +0100 Subject: [PATCH 5/5] Add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44d267999..463c4b132 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `wa_user_created` PostHog event fired on successful user sign-up. [#933](https://github.com/sourcebot-dev/sourcebot/pull/933) - Added `wa_askgh_login_wall_prompted` PostHog event fired when an unauthenticated user attempts to ask a question on Ask GitHub. [#933](https://github.com/sourcebot-dev/sourcebot/pull/933) - Added Bitbucket Server (Data Center) OAuth 2.0 SSO identity provider support (`provider: "bitbucket-server"`). [#934](https://github.com/sourcebot-dev/sourcebot/pull/934) +- Added Bitbucket Server (Data Center) sync all repositories support. [#927](https://github.com/sourcebot-dev/sourcebot/pull/927) ### Changed - Hide version upgrade toast for askgithub deployment (`EXPERIMENT_ASK_GH_ENABLED`). [#931](https://github.com/sourcebot-dev/sourcebot/pull/931)