Skip to content

feat(bitbucket-datacenter): deliver to Bitbucket Data Center - #30

Merged
AlexeyShalaev merged 1 commit into
masterfrom
feat/bitbucket-datacenter
Oct 9, 2026
Merged

AlexeyShalaev merged 1 commit into
masterfrom
feat/bitbucket-datacenter

Conversation

@AlexeyShalaev

Copy link
Copy Markdown
Member

Adds Bitbucket Data Center (8.19 and later) as a provider a hub delivers to: type: bitbucket-datacenter in hub.yml. Like the Bitbucket Cloud and Azure DevOps drivers, it is built from Atlassian's REST reference (the OpenAPI descriptions of 8.0 to 10.5) and tested against stand-ins of its API, not on a live instance.

What it does

  • Configuration. url is required: the instance's base URL, context path included. The REST API is <url>/rest/api/latest.
    • org: is a project key, and topics: are repository labels.
    • Repository URLs can be given as /projects/KEY/repos/<slug>[/browse…] or as clone URLs, /scm/<key>/<slug>.git.
  • Driver (internal/platform/bitbucketdc).
    • Credentials. HTTP access tokens, sent as Authorization: Bearer to the API and to git.
    • Self. Bitbucket has no "who am I" endpoint. touchmark reads the user name from the X-AUSERNAME header of an answer and finds that user with /users?filter=.
    • Pull requests.
      • Opening, editing and closing name the PR's version; a 409 answer is read again and retried once.
      • touchmark closes a PR by declining it.
      • Drafts are native; on an instance with drafts turned off, the PR opens ready.
      • PRs have no labels, and the marker is a Markdown link reference definition, as on Bitbucket Cloud.
    • Who declined a PR comes from its activities. A decline by Bitbucket's system user (the auto-decline of inactive PRs) or by a service user counts as a bot's close.
    • Files. Node type and size come from the browse API, content from the raw API. touchmark computes the blob id; the mode is always 100644.
    • Permissions. Write access is checked through the writer's own /repos?permission=REPO_WRITE view, since repository permissions are visible to admins only. doctor warns on REPO_ADMIN.
    • Stale-PR sweep. It reads /dashboard/pull-requests?role=AUTHOR&user=<name>. An author whose name the reader never learned makes the sweep incomplete.
    • 401 answers. Bitbucket answers 401 both to a refused token and to a user who lacks a permission. A 401 that names the user (X-AUSERNAME, or an AuthorisationException) is a missing permission (ClassPermission). Otherwise one hidden repository would stop the whole provider.
    • Project keys. A key that lists no repository is looked up. An unknown or changed key is ClassNotFound, so no stale PR is swept on its account.
  • Core.
    • Caps.ReaderCloses. On Data Center, an identity that may only read can still decline PRs, and the read key reaches every branch of the hub. plan warns until the reader is in automation_accounts, so that a decline made with it counts as an automatic close, not as the team's decision.
    • Push refusals. "can only be modified through pull requests" maps to rules:pull-request-only; any other branch-permission refusal maps to rules:branch-permissions.
    • Commit author. A service user without an email address authors commits as <id>@touchmark.invalid.
    • setup bitbucket-datacenter refuses: Data Center has no CI to run a hub.
  • Fake. A new bitbucket-datacenter flavor: Bitbucket Cloud's capabilities, a 30 000-byte body, and declined PRs that a person may reopen. It is covered by delivery scenarios, the crash matrix and property simulations.
  • Docs. A Bitbucket Data Center section in the providers guide, the memory concept, the threat model and the platform lists.

Not verified live

The assumptions are listed in docs/guide/providers.md (Bitbucket Data Center):

  • X-AUSERNAME and the users that project and repository tokens act as;
  • how a description renders: whether the HTML comment shows and the link reference definition does not;
  • what at with direction=OUTGOING selects;
  • whether the dashboard lists another user's PRs to the reader;
  • who the activities name for an automatic decline;
  • the texts of push refusals and the headers of 429 answers;
  • what the file APIs answer for symlinks.

Tests

  • Driver. httptest servers that follow the spec's shapes; about 84% coverage.
  • Config. Config, URL and check tests.
  • Delivery. Scenarios, crash matrix and property runs on the fake flavor, on Linux (git 2.47).
  • Full suite. go test ./... on Linux in golang:1.26, plus golangci-lint and the docs check.
  • Review. An independent review found three issues, all fixed:
    • a changed project key resolved to an empty but complete list;
    • a repository gone during a resolve was kept;
    • doctor reported unknown instead of fail for a repository behind 401.

A provider of type bitbucket-datacenter: Bitbucket Data Center 8.19 and later, with HTTP access tokens. Projects are namespaces and repository labels are topics; pull requests have no labels and the marker is a link reference definition, as on Bitbucket Cloud. Declined pull requests are never written to; who declined comes from the activities, and Bitbucket's system user counts as a bot. Caps.ReaderCloses makes plan warn until the reader, which may decline pull requests there, is in automation_accounts.
@AlexeyShalaev
AlexeyShalaev merged commit 685e94c into master Oct 9, 2026
22 checks passed
@AlexeyShalaev
AlexeyShalaev deleted the feat/bitbucket-datacenter branch October 9, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant