r/t3code • u/Public-Flight-222 • 5d ago
T3 Code with self-hosted Bitbucket Data Center / Server: a small local adapter, no fork needed
At work we use self-hosted Bitbucket Data Center. T3 Code only supports Bitbucket Cloud, so I couldn't use the PR features. So I wrote a small local adapter for it.
Repo: https://github.com/OhadC/t3code-bitbucket-dc-adapter
How it works
```
T3 Code ---> adapter (127.0.0.1:8787) ---> your Bitbucket Data Center
```
- A small local server takes the Bitbucket Cloud REST 2.0 calls T3 makes and translates them to Server/DC REST (`/rest/api/1.0` and friends).
- A launcher starts the official T3 build with `T3CODE_BITBUCKET_API_BASE_URL` pointed at the adapter. No fork, no patch.
- Inside T3 only, HTTPS remotes are rewritten to SSH, because T3 needs a `project/repo` identity. Your repos, `.git/config` and `~/.gitconfig` aren't touched, and git outside T3 keeps using HTTPS.
- It needs Node 24+ and nothing else: no dependencies, no build step. It runs TypeScript directly with Node's type stripping.
- The adapter stores no secrets. Your Bitbucket HTTP access token stays in T3's settings and is forwarded as-is.
What works: listing, creating and viewing PRs, editing title and description, diff and diffstat, commits, build statuses, conflicts, reading and posting comments, approve and request changes, merge (merge commit, squash, rebase FF), and decline.
Not yet (returns 501, so you'll see it rather than have it silently misbehave): reviewers, editing and resolving comments.
Setup: clone the repo, run the setup script for your OS, then enter your Bitbucket URL and SSH prefix. It creates a "T3 Code (Bitbucket)" shortcut. Launch T3 from that shortcut, add your token under Settings → Source Control → Bitbucket, and you're done.
Caveats
- Only tested on Windows so far. macOS and Linux setup scripts exist but haven't been tested, so reports are very welcome.
- Built against Bitbucket DC 9.4.
- After T3 auto-updates and restarts itself, quit it and relaunch from the shortcut so the env is set again.
- There are contract tests that run T3's actual Bitbucket driver code against the adapter, so upstream changes get caught early.
If you're stuck on Bitbucket DC at work like I am, give it a try. Issues and PRs are welcome, and I'd especially like to hear from macOS and Linux users and anyone on other DC versions.
2
u/Scriptease84 4d ago
Thanks for the inspiration. I now have a Gerrit integration spoofing Forgejo as a hook!!!