In my Gitlab project, I set the Gitlab variables MY_VAR_DEV
and MY_VAR_PROD
.
Depending on the commit branch, I want a different behavior on the CI/CD pipeline (.gitlab-ci.yml file), according to the below code:
- if [ $CI_COMMIT_BRANCH == "dev" ]; then export ENV="DEV"; fi
- if [ $CI_COMMIT_BRANCH == "prod" ]; then export ENV="PROD"; fi
- TMP_MY_VAR="MY_VAR_${ENV}"
- export MY_VAR=$( eval echo \$$TMP_MY_VAR )
#- ... bla bla with $MY_VAR use
Is there a way to merge the last 2 lines and directly affect to MY_VAR
the value of the evaluation of the MY_VAR_${ENV}
? (I mean no use of TMP_MY_VAR
)
Thank you for your help :)