Last active
July 20, 2018 11:08
-
-
Save qoomon/26867486f4cf02592b7d7eb84442567f to your computer and use it in GitHub Desktop.
GitLab CI - Environment Specific Variables - Community Edition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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