Skip to content
Browse documentation

Workload identity

Bitbucket Pipelines

Use a Bitbucket Cloud deployment step's native OIDC token for one Bulgur environment.

Before you start

This provider uses BITBUCKET_STEP_OIDC_TOKEN from Bitbucket Cloud Pipelines. Set oidc: true on the step and select a deployment environment. The workspace slug determines the issuer and the workspace UUID determines the audience; Bulgur derives both, so the dashboard does not ask you to enter an issuer or audience.

Bitbucket support requires Bulgur CLI or Node SDK 1.4.0 or newer and a matching server version. CLI/SDK 1.3.0 did not include this provider.

A hosted Bulgur Cloud smoke test passed on 2026-11-07 using Bitbucket Pipelines' native step OIDC token and the published bulgur@1.4.0 package against https://api.bulgur.dev. CLI run/pull and Node SDK checks covered token exchange and reuse, a session bounded to five minutes and the configured target, the synthetic fixture read, wrong-policy denial (401), sibling-environment denial (404), write denial (403), CLI credential scrubbing, private pull permissions, and request-local SDK reads. Separately, a hosted metadata-only check passed with the published bulgur@1.4.1 package and a native provider token. Earlier isolated API tests covered provider claim/audience denials and policy revision/disable behavior; those checks are separate from the hosted result.

The token's branch and deployment claims do not prove that a branch is protected or that a run is not a pull request. Configure deployment permissions and branch restrictions in Bitbucket for those controls.

Create the Bulgur policy

In organization settings, create a Bitbucket Pipelines identity. Enter the exact lowercase workspace slug, workspace UUID, repository UUID, exact branch name, and deployment environment UUID. Use canonical lowercase UUID strings with hyphens and no braces. The workspace UUID is used to construct the token audience ari:cloud:bitbucket::workspace/<workspace-uuid>.

Set the branch policy to the branch name Bitbucket places in the signed token, such as main. Select a non-Shared Bulgur environment. A matching deployment step can read that environment and its inherited Shared values.

Bulgur fieldWhere to find it
Workspace slugLowercase letters, digits, hyphens, and underscores from the workspace URL/settings; up to 63 characters.
Workspace IDUUID in the workspace OIDC provider details.
Repository IDRepository UUID in repository settings or OIDC details.
BranchExact branch name, such as main; no wildcard.
Deployment environment IDUUID for the Bitbucket deployment environment, included in the signed sub; the display name is informational and is not required by the verifier.

A signed branch value is only a branch match. Restrict who can deploy to the selected Bitbucket environment and who can change pipeline configuration.

Enable OIDC on the deployment step

Store the Bulgur identity UUID as a Bitbucket deployment or repository variable named BULGUR_IDENTITY_ID. The step must set oidc: true and select the deployment environment whose UUID you pinned in Bulgur.

yaml
pipelines:
  branches:
    main:
      - step:
          name: Deploy
          deployment: production
          oidc: true
          script:
            - export BULGUR_AUTH=bitbucket-oidc
            - npx bulgur run -- ./deploy.sh

The example expects BULGUR_IDENTITY_ID to be configured in Bitbucket variables. Bitbucket supplies BITBUCKET_STEP_OIDC_TOKEN; do not create your own token variable.

Use the Node SDK

The SDK reads BITBUCKET_STEP_OIDC_TOKEN from the OIDC-enabled deployment step. It has no Bitbucket package dependency. Use Node.js 18 or newer with Bulgur SDK 1.4.0 or newer and a matching server.

js
const { loadValues } = require("bulgur");

async function main() {
  return await loadValues({
    auth: "bitbucket-oidc",
    identityId: process.env.BULGUR_IDENTITY_ID,
  });
}

main().catch(() => {
  console.error("Could not load Bulgur values");
  process.exitCode = 1;
});

Token lifetime and revocation

Bitbucket source tokens can be reused until expiry; the verifier accepts up to 12 hours 5 minutes plus 30 seconds of clock tolerance. Bulgur sessions last at most five minutes. Changing or disabling the policy invalidates active Bulgur sessions, but does not revoke the source token at Bitbucket.