1

I would like to define an environment variable called ENVIRONMENT as follows:

  • if BUILDKITE_BRANCH == 'main', then ENVIRONMENT=production
  • if BUILDKITE_BRANCH != 'main', then ENVIRONMENT=staging

I'd like this variable to be defined at the pipeline level if possible, since I have other pipeline variables that would depend on it.

Here's some pseudo-code to show what I would like to do:

env:
  ENVIRONMENT: $(if BUILDKITE_BRANCH == 'main' then "production" else "staging")
  OTHER_VAR: other-var-$ENVIRONMENT

steps:
  commands:
    - echo $ENVIRONMENT
    - echo $OTHER_VAR

Does anyone have any creative solutions or work-arounds?

DV82XL
  • 5,350
  • 5
  • 30
  • 59

0 Answers0