'Gitlab CI - Compute variable name based off another variable
I am trying to use a variable that is compiled partly from another variable (based off the branch name). I have environmental variables configured in Gitlab like so:
Key: s3_bucket_development
Value: https://dev.my-bucket.com
Key: s3_bucket_production
Value: https://prod.my-bucket.com
The branch that I am deploying on is called development and the idea is to be able to call the s3_bucket_development
variable dynamically depending on the branch it is currently on.
So far I have managed to get this far:
eval echo $s3_bucket_${CI_COMMIT_REF_NAME}
Unfortunately the above only outputs development
to the console, not the value of $s3_bucket_development
which should be https://dev.my-bucket.com
Not sure what i've done wrong here?
Copied a bit from this link here but does not seem to work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|