Is there a way to use predefined variable inside custom variable in gitlab ci like this:
before_script:
- cat "${$CI_COMMIT_REF_NAME}" >> .env
to extract the name of branch from $CI_COMMIT_REF_NAME and use it as a name of custom variable
Update:

Check if this matches gitlab-org/gitlab-runner issue 1809:
Description
- In the
.gitlab-ci.ymlfile, a user can define a variable and use it in another variable definition within the same.gitlab-ci.ymlfile.- A user can also use a GitLab pre-defined variable in a variable declaration.
Example
variables: variable_1: "foo" # here, variable_1 is assigned the value foo variable_2: "${variable_1}" # variable_2 is assigned the value variable_1. # The expectation is that the value in variable_2 = value set for variable_1
If it is, it should be completed/implemented for GitLab 14.1 (July 2021)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With