Environment Variables

When the agent invokes your build scripts it passes in a set of standard Buildkite environment variables, along with any that you've defined in your build configuration. You can use these environment variables in your build steps and agent hooks.

Provided by Buildkite

The following environment variables are automatically provided to every job, and can’t be overriden by your pipeline configuration.

CIAlways "true".
BUILDKITEAlways "true".
BUILDKITE_REPOThe repository of your pipeline.

Example: "git@github.com:acme-inc/my-project.git"

BUILDKITE_COMMITThe commit of the build.

Example: "83a20ec058e2fb00e7fa4558c4c6e81e2dcf253d"

BUILDKITE_MESSAGEThe message associated with the build, usually the commit message.

Example: "Added a great new feature"

BUILDKITE_BRANCHThe branch being built.

Example: "master"

BUILDKITE_TAGThe name of the tag being built, if this build was triggered from a tag.

Example: "v1.2.3"

BUILDKITE_JOB_IDInternal UUID Buildkite uses for this job.

Example: "e44f9784-e20e-4b93-a21d-f41fd5869db9"

BUILDKITE_BUILD_IDInternal UUID Buildkite uses for this build.

Example: "9e08ef3c-d6e6-4a86-91dd-577ce5205b8e"

BUILDKITE_BUILD_NUMBERThe build number.

Example: "1514"

BUILDKITE_BUILD_URLThe url for this build on Buildkite.

Example: "https://buildkite.com/acme-inc/my-project/builds/1514"

BUILDKITE_AGENT_NAMEName of the agent running the job.

Example: "my-agent-1"

BUILDKITE_LABELThe label/name of the current job.

Example: ":hammer: Specs"

BUILDKITE_COMMANDThe command that will be run for the job.

Example: "script/buildkite/specs"

BUILDKITE_TIMEOUTThe number of minutes until Buildkite automatically cancels this job, if a timeout has been specified.

Example: "15" for 15 minutes, or "false" if no timeout is set

BUILDKITE_ARTIFACT_PATHSThe artifact paths to upload after the job, if any have been specified.

Example: "tmp/capybara/**/*;coverage/**/*"

BUILDKITE_CLEAN_CHECKOUTWhether the build should perform a clean checkout.

Example: "true" or "false"

BUILDKITE_BUILD_CHECKOUT_PATHThe path where the agent has checked out your code for this build.

Example: "/var/lib/buildkite-agent/builds/agent-1/pipeline-2"

BUILDKITE_ORGANIZATION_SLUGThe organization name on Buildkite as used in URLs.

Example: "acme-inc"

BUILDKITE_PIPELINE_SLUGThe pipeline slug on Buildkite as used in URLs.

Example: "my-project"

BUILDKITE_PIPELINE_PROVIDERThe ID of the source code provider for the pipeline’s repository.

Example: "github"

BUILDKITE_PIPELINE_DEFAULT_BRANCHThe default branch for this pipeline.

Example: "master"

BUILDKITE_SOURCEThe source of the event that created the build.

Example: "webhook", "api", "ui", "trigger_job", or "schedule"

BUILDKITE_BUILD_CREATORThe name of the user who created the build.

Example: "Tracy Tester"

BUILDKITE_BUILD_CREATOR_EMAILThe notification email of the user who created the build.

Example: "tracy@acme-inc.com"

BUILDKITE_BUILD_CREATOR_TEAMSA colon separated list of team names that the build creator belongs to.

Example: "everyone:platform"

BUILDKITE_PULL_REQUESTThe number of the pull request if this branch is a pull request.

Example: "123" for pull request #123, or "false" if not a pull request.

BUILDKITE_PULL_REQUEST_REPOThe repository URL of the third-party pull request.

Example: "git://github.com/acme-inc/my-project.git", or "" if not a pull request.

BUILDKITE_PULL_REQUEST_BASE_BRANCHThe base branch that the pull request is targetting.

Example: "master", or "" if not a pull request.

BUILDKITE_REBUILT_FROM_BUILD_IDThe UUID of the original build this was rebuilt from.

Example: "4735ba57-80d0-46e2-8fa0-b28223a86586", or "" if not a rebuild.

BUILDKITE_REBUILT_FROM_BUILD_NUMBERThe UUID of the original build this was rebuilt from.

Example: "1514", or "" if not a rebuild.

Defining your own

You can define environment variables in your jobs in a few ways, depending on the nature of the value being set:

  • Pipeline settings — for values that are not secret.
  • Build pipeline configuration — for values that are not secret.
  • An environment or pre-command agent hook — for values that are secret or agent-specific.