How to set an ENV var for all steps in the pipeline

I though that top-level env created environment variables which affected every single step in the pipeline. Example:

  MYVAR: SomeValue

  - label: step1
    command: echo $MYVAR

Comes up empty.

What is the recommended method of doing this? thanks

Hello @js-cb :slightly_smiling_face:
Thanks for reaching out!

I tried this on my end it works fine.


  MYVAR: "SomeValue"
  - label: "step1"
     command: "echo $MYVAR"

Setting the env variable before steps makes it global and available to all steps. You can confirm this by checking the Environment tab it should have MYVAR="SomeValue" as a variable set.

Let me know if this helps!

i @stephanieat
Is your buildkite running a different version than mine? (I don’t even know if there’s such a thing)

I have set that in 2 places: the pipeline yml and the pipeline “pre” steps which load the actual yml
Neither of them kick in

I went back to hardcoded env vars for every step. That works regardless. But it would be nice to find out why the other way does not work

Hey @js-cb I’m using buildkite-agent version 3.42.0 . Can you check which version you are running might be an older version, use " buildkite-agent --v " . Incase its an older agent you can get a newer one , under the respective agent installer

I can also take a closer look at the build for you, please send the build link to

Our version is 3.40.0

Hmm @js-cb that’s strange. Please send an email with a link to the build to , I’m curious to see, what’s causing this as well

1 Like