--- title: "ADR 0027: Bitbucket Data Center event identity and clone URL handling" --- * Status: accepted * Code: [`pkg/provider/bitbucketdatacenter/parse_payload.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/bitbucketdatacenter/parse_payload.go), [`pkg/provider/bitbucketdatacenter/bitbucketdatacenter.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/bitbucketdatacenter/bitbucketdatacenter.go) ## Context Bitbucket Data Center has no owner, only a project key, and personal repositories live under a project key prefixed with `~`. Webhook payloads arrive with event keys that differ from Bitbucket Cloud, and carry clone links that the provider later uses to build git credentials from the repository token. ## Decision * The project key is stored as `Organization`. `ParsePayload` first saves the raw key into `BBDCProjectKey` and `Provider.projectKey`, then strips `~` from `Organization`. API calls that need the real key (commit status, for example) read `BBDCProjectKey`, or the project key annotation on the PipelineRun when present, because the stripped value would not address a personal repository. * The event URL has a trailing `/browse` removed, and the provider `baseURL` is derived from only the scheme and host of that URL. The payload carries no explicit base URL. * Pull request events are recognised by the `pr:` prefix of `X-Event-Key`. Push events are matched on the exact key `repo:refs_changed`, because the `repo:` prefix is shared with other event families. * The HTTP clone link is the only one used; SSH clone links are ignored. * The clone URL must be on the same host as the repository URL. A payload whose clone link points elsewhere is rejected before any git credentials are built, so the repository token cannot be sent to a host the payload chose. * `SetClient` appends `/rest` to the provider URL if missing, strips a trailing slash, and builds the go-scm stash client from the URL with `/rest` removed. Token validity is checked with a `Users.Find` call. * When the changed-file or file-content lookups are given an empty SHA/revision, go-scm reads from the default branch. That is how default-branch provenance is obtained. ## Consequences * Code that needs the Data Center project key must read `BBDCProjectKey`, not `Organization`. * SSH clone links are never used for the clone URL. * A payload whose clone URL host differs from its repository URL host is refused.