Buildkite Agent Runtime
The buildkite-agent binary provides subcommands for interacting with Buildkite from within running job steps — creating annotations, uploading artifacts, sharing state between jobs, generating dynamic pipelines, requesting OIDC tokens, and more. This skill covers the command syntax, flags, and patterns for every in-job subcommand.
Quick Start
A step that runs tests, annotates failures, uploads coverage, and stores a result flag for downstream jobs:
A downstream step reading that state:
Annotations
Surface build results directly on the build page. Annotations support Markdown and HTML.
Creating annotations
Key flags
Replacing vs appending
- Same
--contextwithout--appendreplaces the annotation; with--appendappends below existing content. - Always use a stable
--contextvalue so reruns update the same annotation instead of creating duplicates.
For pipeline-level
notify:configuration, see the buildkite-pipelines skill.
Artifacts
Upload files as build artifacts, download them in later steps or other builds, and search by glob.
Upload
Download
Search
For complete flag tables, see references/flag-reference.md.
For the declarative
artifact_paths:YAML key, see the buildkite-pipelines skill. Forbk artifactCLI commands, see the buildkite-cli skill.
Meta-data
A build-wide key-value store for sharing state between jobs. Set a value in one job, read it in any other job in the same build.
Set
Get
Use --default to return a fallback value instead of a non-zero exit when the key is missing: buildkite-agent meta-data get "deploy-env" --default "staging".
Check existence
Common patterns
Block step field values are stored automatically as meta-data. Retrieve them by field key:
Raw webhook payloads are available in webhook-triggered builds, while the webhook data remains cached. Read the special buildkite:webhook key when automation needs fields that are not promoted to first-class environment variables, such as the original pull request comment body.
Pipeline Upload
Dynamically add steps to a running build. The core mechanism behind dynamic pipelines — generate YAML at runtime and upload it.
Basic usage
Replace mode
By default, uploaded steps are appended after the current step. Use --replace to replace the entire remaining pipeline:
Key flags
For pipeline YAML syntax and step types, see the buildkite-pipelines skill.
OIDC Tokens
Request short-lived OpenID Connect tokens from within a job step for authenticating to external services (cloud providers, package registries) without static credentials.
Basic token request
Cloud provider authentication
Key flags
For end-to-end OIDC auth flows, cloud provider setup, and token claim details, see the buildkite-secure-delivery skill.
Step Management
Read or modify step attributes at runtime. Useful for conditional logic within steps and build automation.
Get step attributes
Update step attributes
Cancel a step
Key flags
Distributed Locks
Coordinate parallel jobs within a build using distributed mutex locks. Prevents race conditions when multiple jobs access shared resources.
Acquire / release pattern
Do / done pattern (one-time setup)
Run a setup task exactly once across all parallel jobs:
Key flags
Environment
Inspect and modify the job's environment variables. Primarily useful for debugging lifecycle hooks and understanding what environment changes hooks made.
Key flags
Debugging hooks
The env dump command is particularly useful in lifecycle hooks to see what prior hooks changed:
For agent lifecycle hooks and
buildkite-agent.cfgconfiguration, see the agent hooks and agent configuration documentation.
Secrets
Retrieve cluster secrets at runtime from within job steps. Secrets retrieved this way are automatically added to the log redactor.
Basic usage
Key flags
Multiple secret keys can be requested at once: buildkite-agent secret get KEY1 KEY2 KEY3.
By default, secret get automatically registers retrieved values with the log redactor, masking them as [REDACTED] in subsequent output.
For setting up cluster secrets, see the Buildkite Secrets documentation. For the declarative
secrets:pipeline YAML key, see the buildkite-pipelines skill.
Log Redaction
Add values to the build log redactor at runtime so they are masked in all subsequent output. Use this for dynamically-retrieved secrets that were not declared via secrets: or buildkite-agent secret get.
Basic usage
Multiple values
When to use redactor vs secret get
Tool Signing
Sign pipeline YAML so that agents can verify step integrity before execution. The tool sign command takes a pipeline file (not individual steps) and annotates it with signatures.
Sign a pipeline from a file
Sign via the GraphQL API
Generate a signing key pair
Key flags
Note: There is no
tool verifycommand. Signature verification is handled internally by the agent when it receives a job.
For pipeline signing configuration and rollout strategy, see the buildkite-secure-delivery skill.
Common Mistakes
Additional Resources
Reference Files
references/flag-reference.md— Complete flag tables for all subcommands including upload, download, search, shasum, annotate, meta-data, pipeline upload, oidc, step, lock, env, secret, redactor, and toolreferences/patterns-and-recipes.md— Advanced multi-subcommand patterns: test failure annotation pipelines, cross-job state machines, OIDC-authenticated Docker push, parallel job coordination with locks, environment debugging


