Skip to content
Browse documentation

Workload identity

Buildkite pipelines

Use an audience-bound Buildkite job token for short-lived access to one Bulgur environment.

Before you start

Buildkite's agent requests a signed job token for the fixed Bulgur audience https://api.bulgur.dev. Bulgur checks organization ID, pipeline ID, exact ref, step key, and an allowed pipeline source.

Buildkite 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 from a Buildkite Linux small agent using a native five-minute 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 denials and policy revision/disable behavior; those checks are separate from the hosted result.

The signed branch/ref is not proof of protected-branch or pull-request status. Limit who can change the pipeline, step keys, and agents with access to the Buildkite OIDC endpoint.

Create the Bulgur policy

In organization settings, create a Buildkite identity. Enter canonical lowercase UUIDs for the Buildkite organization and pipeline, the exact full Git ref, and the step key from your pipeline YAML. Choose one or more permitted token sources: ui, api, webhook, trigger_job, or schedule.

A step key identifies the Buildkite command step, not its display name. Make it stable and avoid reusing that key for a different trusted operation.

Bulgur fieldValue
Organization IDBuildkite organization UUID.
Pipeline IDPipeline UUID from Buildkite pipeline settings/API.
RefExact full ref, for example refs/heads/main or refs/tags/v1.2.0.
Step keyExact key value on the trusted step in pipeline YAML.
Allowed sourcesOne or more of ui, api, webhook, trigger_job, schedule.

Refs must use refs/heads/... or refs/tags/...; wildcards and whitespace are rejected. Keep pipeline editing and OIDC-agent access limited to trusted users.

Request a short-lived token and run the CLI

The CLI requires OS trusted CA roots for HTTPS. For container jobs, use an image with CA certificates installed; the hosted check passed with node:22-bookworm after node:22-bookworm-slim lacked OS CA roots. The CLI consumes BULGUR_BUILDKITE_ID_TOKEN; it does not run the Buildkite agent command itself. Request the token in the Buildkite job before invoking Bulgur, and do not enable shell tracing around the command.

sh
BULGUR_BUILDKITE_ID_TOKEN="$(buildkite-agent oidc request-token --audience https://api.bulgur.dev --lifetime 300)" || exit 1
export BULGUR_BUILDKITE_ID_TOKEN
export BULGUR_AUTH=buildkite-oidc
export BULGUR_IDENTITY_ID=<bulgur-identity-id>
npx bulgur run -- ./deploy.sh
unset BULGUR_BUILDKITE_ID_TOKEN

A five-minute source-token lifetime is recommended. The verifier allows source tokens up to one hour. Use CLI 1.4.0 or newer with a server that supports Buildkite.

Use the Node SDK

The SDK reads BULGUR_BUILDKITE_ID_TOKEN from its process environment. It does not spawn buildkite-agent; request and export the token in your pipeline step before starting the Node process. 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: "buildkite-oidc",
    identityId: process.env.BULGUR_IDENTITY_ID,
  });
}

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

Keep the token in process memory for the shortest practical time. Do not put it in a static pipeline variable, artifact, or log.

Token lifetime and revocation

Buildkite tokens can be reused until expiry and can last up to one hour; request the recommended five-minute lifetime. The verifier requires the token's jti claim but does not keep a one-time replay ledger. Bulgur sessions last at most five minutes. Editing, disabling, or deleting the policy revokes active Bulgur sessions, not the Buildkite source token.