Buildkite Pipelines
Query Buildkite CI/CD pipelines using the bk CLI.
Prerequisites
The bk CLI must be installed and configured. Run bk configure to set up authentication.
Commands
Get Build Status
# Build summary (number, state, branch, URL, job counts)
bk build view -p org/pipeline -o json | jq '{number, state, branch, web_url, jobs: (.jobs | group_by(.state) | map({(.[0].state): length}) | add)}'
# Specific build number
bk build view -p org/pipeline 12345 -o json | jq '{number, state, branch, web_url, jobs: (.jobs | group_by(.state) | map({(.[0].state): length}) | add)}'
# Latest build on a specific branch
bk build view -p org/pipeline -b my-feature -o json | jq '{number, state, branch, web_url, jobs: (.jobs | group_by(.state) | map({(.[0].state): length}) | add)}'
List Jobs
Jobs are included in build view output. Use JSON output and jq to filter:
# All jobs in a build
bk build view -p org/pipeline 12345 -o json | jq '.jobs[] | {id, name, state}'
# Failed jobs only (includes timed_out)
bk build view -p org/pipeline 12345 -o json | jq '.jobs[] | select(.state == "failed" or .state == "timed_out") | {id, name, state, web_url}'
# Running jobs
bk build view -p org/pipeline 12345 -o json | jq '.jobs[] | select(.state == "running") | {id, name}'
Get Job Log
# Get full job log
bk job log <job-id> -p org/pipeline -b 12345
# Strip timestamps
bk job log <job-id> -p org/pipeline -b 12345 --no-timestamps
# Last N lines
bk job log <job-id> -p org/pipeline -b 12345 | tail -n 100
Search Job Logs
# Search for pattern with context
bk job log <job-id> -p org/pipeline -b 12345 --no-timestamps | grep -i "error" -C 2
# Search for multiple patterns
bk job log <job-id> -p org/pipeline -b 12345 --no-timestamps | grep -iE "(error|failed|exception)"
Watch Build Progress
Note: Unlike other commands, bk build watch only accepts pipeline slug (not org/pipeline format).
# Watch build in real-time
bk build watch -p pipeline 12345
# Watch latest build on branch
bk build watch -p pipeline -b my-feature
Test Runs
ruby scripts/test_runs.rb <org/pipeline> <build_number>
Shows Test Engine runs for a build with run IDs, state, and suite slugs. Use run IDs with the test-engine skill to get failed tests.
Common Workflows
Debug a failed build
Wait for the build to finish (or start failing):
bk build watch -p pipeline -b my-branchFind failed jobs:
bk build view -p org/pipeline -b my-branch -o json | jq '.jobs[] | select(.state == "failed" or .state == "timed_out") | {id, name, web_url}'Get logs for a failed job:
bk job log <job-id> -p org/pipeline -b <build-number> --no-timestamps | tail -n 200Search for errors:
bk job log <job-id> -p org/pipeline -b <build-number> --no-timestamps | grep -i error -C 3
Get test failures
# Get test run IDs
ruby scripts/test_runs.rb buildkite/buildkite 174608
# Then use test-engine skill with the run ID