Buildkite CLI api command

The bk api command allows you to interact with the Buildkite API from the command line.

Interact with the Buildkite API

Interact with either the REST or GraphQL Buildkite APIs.

bk api [<endpoint>] [flags]

Arguments

Argument Description
[<endpoint>] API endpoint to call

Flags

Flag Description
-d, --data=STRING Data to send in the request body; use - to read from stdin
-f, --file=STRING File containing GraphQL query
-H, --headers=HEADERS Headers to include in the request
-X, --method=STRING HTTP method to use
--analytics Use the Test Analytics endpoint
--debug Log HTTP API traffic to stderr; bodies may contain sensitive data
--org=STRING Organization slug for this invocation (overrides environment and configuration)

Examples

To get a build:

bk api /pipelines/example-pipeline/builds/420

To create a pipeline:

bk api --method POST /pipelines --data '
{
"name": "My Cool Pipeline",
"repository": "git@github.com:acme-inc/my-pipeline.git",
"configuration": "steps:\n - command: env"
}
'

To create a pipeline with a body from stdin:

cat pipeline.json | bk api /pipelines --data -

To update a cluster:

bk api --method PUT /clusters/CLUSTER_UUID --data '
{
"name": "My Updated Cluster",
}
'

To get all test suites:

bk api --analytics /suites

Run GraphQL query from file:

bk api --file get_build.graphql