I would like to define an environment variable called ENVIRONMENT
as follows:
- if
BUILDKITE_BRANCH == 'main'
, thenENVIRONMENT=production
- if
BUILDKITE_BRANCH != 'main'
, thenENVIRONMENT=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?