Concat variable names in GitLab

Solution from @nik will work only for bash. For sh will work:

before_script:
  - variableName=...
  - export wantedValue=$( eval echo \$$variableName )

We found a solution using indirect expansion (bash feature):

before_script:
 - variableName=${GITLAB_USER_ID}_CI_K8S_PROJECT
 - export wantedValue=${!variableName}

But we also recognised, that our setup was somehow stupid: It does not make sense to have multiple branches for each user and use prefixed variables, since this leads to problems such as the above and security concerns, since all variables are accessible to all users.

It is way easier if each user forks the root project and simply creates a merge request for new features. This way there is no renaming/prefixing of variables or branches necessary at all.

Tags:

Yaml

Gitlab Ci