Parameterized GitLab CI-File Templates
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Currently GitLab ci-file templates are implemented as copy-paste style text insertion of individual job sections without any possibility of parameterized text replacement. My understanding is that only an entire section such as "script:" can be replaced, but please correct me if there is already some way to parameterize a template.
We need this syntax, or something that achieves the same functionality:
deployImageToDev-01: <<: *deployImageToDevTemplate(POD_ID=01)
This would replace all instances of $POD_ID with 01 in the template definition.
Currently template definitions are unnecessarily long due to the need to replace text that could easily be parameterized if there was some mechanism in GitLab to do it. Example:
deployImageToDev-01:
<<: *deployImageToDevTemplate
script:
- ./.gitlab-deploy-image.sh -e dev -x 01 -i $APP_ID -r $DEPLOY_REGION -v $FEATURE_DEPLOY_VERSION -p proxy.local -n 1 -d
only:
variables:
- $DEPLOY_DEV_01 == "true"
refs:
- /^feature//*/
deployImageToDev-02:
<<: *deployImageToDevTemplate
script:
- ./.gitlab-deploy-image.sh -e dev -x 02 -i $APP_ID -r $DEPLOY_REGION -v $FEATURE_DEPLOY_VERSION -p proxy.local -n 1 -d
only:
variables:
- $DEPLOY_DEV_02 == "true"
refs:
- /^feature//*/
The only text that differs between these 2 blocks is the string "01" and "02", which should be possible to parameterize.