Listing environment variables used to trigger a Buildkite pipeline
This post's featured URL for sharing metadata is https://www.jvt.me/img/profile.jpg.
If you're using Buildkite for your builds, you may sometimes want to work out what environment variables were used to trigger a given build.
Although the Web UI allows you to see the environment variables a given step in the build takes, you can't see the job's environment variables itself, which can be frustrating if you're using them to allow parameterising your builds.
Fortunately, Buildkite provides a GraphQL API, so we can run the following query:
query environmentVariables {
build(slug: "example/something/1234") {
env
}
}
This would then output, for instance:
{
"data": {
"build": {
"env": [
"USER=jamie.tanna",
"AWS_REGION=eu-west-1"
]
}
}
}