Pipeline level env vars


#1

With the previous method of defining pipelines it was possible to define env vars that applied to every step in the downloaded pipeline, however the new syntax only allows step level env which is not automatically passed to each downloaded step.

In the previous thread it was suggested that this should work:

env:
  SOMETHING: "test"

steps:
  - command: "buildkite-agent pipeline upload"

However this didn’t seem to work for me.

The only work around I’ve got at the moment is to process the variables in the downloaded pipeline like this:

- label: ':rocket: Deploy'
  command: deploy.sh
  plugins:
    docker#v2.0.0:
      image: google/cloud-sdk
      environment:
      - PROJECT=$PROJECT
      - CLUSTER=$CLUSTER

#2

@jam13 ah, you’re totally right - that’s a bug! :bug: I was able to reproduce this locally and I’ve got a fix ready to roll out as soon as it’s gone through some internal review tomorrow. Will reply here once it’s shipped to production.

Sorry for my confusion earlier, and thanks for taking the time to get back to me about it!


#3

Will pipeline level env also be supported in the pipeline.yml from source? That might be handy if so.


#4

You can do this now in the pipeline.yml file:

env:
  BLAH: "blah"

steps:
  - command: "echo $BLAH"

…if that’s what you mean? In that example, BLAH will be copied to all steps that are defined in the current file.


#5

Yes that’s what I mean, thanks.


#6

@jam13 :wave: sorry for the delay with this one, but I just wanted to let you know that I pushed a fix for this - so…

env:
  SOMETHING: "test"

steps:
  - command: "buildkite-agent pipeline upload"

…will now work as you’d expect! Thanks again for submitting the issue!


#7

@jam13 I just wanted to check back and see if everything’s with your pipeline now?


#8

Will modify the pipeline and try a build.


#9

Works as expected now. Thanks for the quick response.