Skip to content

feat(source-control): Bitbucket Data Center repositories - #18241

Closed
OhadC wants to merge 2 commits into
pingdotgg:mainfrom
OhadC:bitbucket-dc/2-repositories
Closed

OhadC wants to merge 2 commits into
pingdotgg:mainfrom
OhadC:bitbucket-dc/2-repositories

Conversation

@OhadC

@OhadC OhadC commented Oct 11, 2026 •

Copy link
Copy Markdown

A self-hosted Bitbucket remote (Data Center or Server) is classified as Bitbucket Cloud, so T3 Code sends its requests, with any Cloud token, to api.bitbucket.org (#14591). There is also no way to look up or clone a Data Center repository. This PR adds Data Center as its own host, @t3tools/source-control-bitbucket-server, for repositories. Proposed in #10837. It stacks on #18240; pull requests follow in #18242. Only the last commit is new here. GitHub can't base a PR on a fork branch, so this one targets main and also shows #18240's commit.

Fixes #14591. It supersedes #14593, which marks these hosts unsupported until Data Center support exists.

Summary

 remote host
   bitbucket.org                 -> bitbucket          (Cloud, unchanged)
-  any other `bitbucket` label   -> bitbucket          (sent to api.bitbucket.org)
+  any other `bitbucket` label   -> bitbucket-server   (sent only to the configured host)
packages/source-control-bitbucket-server/
├── client/definition.ts                # kind, labels, PR URL shape, no publish
└── server/
    ├── BitbucketServerApi.ts           # REST 1.0 over HttpClient: lookup, clone URLs, default branch, checkout
    ├── BitbucketServerSourceControlProvider.ts
    ├── bitbucketServerPullRequests.ts  # branch pull request status
    └── driver.ts                       # pullRequests: null until #18242
  • Remotes: https://host/scm/KEY/repo.git, ssh://git@host:7999/KEY/repo.git, ~user personal repositories, and hosts served under a context path. Repository identity drops the context path and /scm/, so a clone URL and a browse URL name the same repository.
  • Credentials: one host URL plus an HTTP access token in Settings → Source Control. The token goes in the secret store, like the Cloud token. T3CODE_BITBUCKET_SERVER_URL and T3CODE_BITBUCKET_SERVER_TOKEN are the fallback. The token is only sent to the configured host. A remote on any other host fails with a clear error.
  • Not offered: publishing (publishDescription: null). The docs say to create the repository on the host and clone it.
  • Outside the package: detection in shared/sourceControl.ts, the PR URL shape in shared/changeRequestUrl.ts, registration in builtInDrivers.ts, sourceControlHostSecrets.ts, and client-runtime, the settings search entry, a section in docs/user/source-control.md, plus knip, release smoke, and the lockfile.

Evidence

Driven in a dev server against a real Data Center instance with a throwaway personal repository. The host name is blurred. Here the host is configured through the T3CODE_BITBUCKET_SERVER_* fallback, which is why the Settings fields are empty while the row reads Authenticated.

Before: no Data Center host After: Data Center authenticated
l2-before-settings l2-after-settings
Clone picker offers Data Center Lookup resolves a ~user repository
l2-after-picker l2-after-clone

Tests: BitbucketServerApi.test.ts (URL shapes, context paths, token only sent to the configured host, checkout), BitbucketServerSourceControlProvider.test.ts, RepositoryIdentityResolver.test.ts, changeRequestUrl.test.ts, sourceControl.test.ts, sourceControlClients.test.ts. Typecheck and knip pass.

Merge Danger

Door: two-way

Blast Radius: self-hosted Bitbucket

Remotes on a bitbucket host other than bitbucket.org stop being treated as Cloud. Anyone relying on T3CODE_BITBUCKET_API_BASE_URL to reach such a host through the Cloud client loses that path. Per #14591's triage, that path could not work against Data Center anyway. One Data Center host per server.

🤖 Generated with Claude Code — Claude Opus 5.5 in T3 Code

OhadC added 2 commits October 11, 2026 18:09
- Host port: `fetchRemoteRef` fetches any remote ref into a local branch, for hosts whose pull
  request refs are not branches.
- Bitbucket Cloud: the pull request id normalizer and the change request mapper are exported, so
  a second Bitbucket host can share them.
- Client definitions: a null `publishDescription` keeps a host out of the Publish picker.
- Desktop: the bundled server trusts the OS certificate store, for hosts behind a corporate CA.
Self-hosted Bitbucket (Data Center or Server) is its own host, `bitbucket-server`, in
`@t3tools/source-control-bitbucket-server`, next to Bitbucket Cloud.

- Remotes on a host with a `bitbucket` label are Data Center; `bitbucket.org` stays Cloud.
  `/scm/` and any context path are dropped from the repository identity, so HTTPS and SSH
  remotes of one repository match.
- Clone, look up, and create pull requests from the branch flow over the REST API. Publishing is
  refused, and the host is left out of the Publish picker.
- Host URL and HTTP access token are saved from Source Control settings, with the token in the
  secret store. `T3CODE_BITBUCKET_SERVER_URL` and `T3CODE_BITBUCKET_SERVER_TOKEN` are the fallback.
- Pull request URLs parse and build as `PROJECTKEY/repo-slug`, keeping the web port and context
  path. The client definition sits ahead of Cloud so Data Center URLs are attributed to it.
@github-actions github-actions Bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Oct 11, 2026
@github-actions github-actions Bot added the size:XXL 1,000+ changed lines (additions + deletions). label Oct 11, 2026

Copy link
Copy Markdown
Member

Note

This comment is posted by Julius' dot

#14591's triage approves stopping misrouted Cloud requests and treats Data Center support as a separate feature. This PR adds that integration, while #10837 still awaits scope approval. I'm closing it under the prior-approval requirement. Please obtain maintainer approval in #10837 and link it when requesting reconsideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

2 participants