Skip to content

Instantly share code, notes, and snippets.

@qoomon
Last active July 20, 2018 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qoomon/26867486f4cf02592b7d7eb84442567f to your computer and use it in GitHub Desktop.
Save qoomon/26867486f4cf02592b7d7eb84442567f to your computer and use it in GitHub Desktop.
GitLab CI - Environment Specific Variables - Community Edition
# assume you've set following environment variables
# AWS_ACCESS_KEY__production="111111"
# AWS_ACCESS_KEY__sandbox="222222"
before_script:
# declares environment spesific variables
- ENV_VAR_SUFFIX="__${CI_ENVIRONMENT_NAME}"; for var in $(compgen -e | grep "${ENV_VAR_SUFFIX}$"); do declare -xg ${var%${ENV_VAR_SUFFIX}}="${!var}"; done
job:
environment: sandbox
script:
# In this case AWS_ACCESS_KEY will have the value of environment variable AWS_ACCESS_KEY__sandbox
- echo $AWS_ACCESS_KEY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment