Listing environment variables used to trigger a Buildkite pipeline

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"
      ]
    }
  }
}

Written by Jamie Tanna's profile image Jamie Tanna on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #buildkite.

This blog post is 100% human-written, and has nothing derived from LLMs (be it code, editorial support or prose).

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.