buildkite / feedback

Got feedback? Please let us know!
https://buildkite.com
25 stars 24 forks source link

Conditional environment variable #498

Closed rsimiciuc closed 5 years ago

rsimiciuc commented 5 years ago

Is it possible to set environment variables based on the branch being built?

I have to set different credentials and url variable if the branch is master

For example it will be useful if code blocks are accepted in the environment block like:

environment variables:

if [[ "$BUILDKITE_BRANCH" = "master" ]]; then URL="productionurl.com" else URL="qa.site.com" fi

adis-io commented 5 years ago

Are you using docker or something? https://buildkite.com/docs/agent/v3/hooks - look at hooks, especially pre-command hook

BTW there's slack - https://chat.buildkite.community/

toolmantim commented 5 years ago

Sorry, that’s not possible in pipeline.yml — you can use a repository hook to export it with that same conditional logic though! I’ll close this, as it’s on the feedback repo, but feel free to keep replying if you need. Alternatively, the Slack @adis-io mentioned, or support@buildkite.com 😊