I need to set a list of values for helm, which works when I run it locally or in the Gitlab pipeline if it's directly in the script section.
However, if I pass the list in as a job variable it gets interpreted as a single string.
For example this would work:
.openshift_template: &openshift_template
stage: deploy
tags:
- $RUNNER
environment: $ENVIRONMENT
script:
- >
helm upgrade $RELEASE helm/charts/ -f ./helm/charts/values.yaml
--install
--set Hosts={host1\,host2\,host3}
This, however would not work:
.openshift_template: &openshift_template
stage: deploy
tags:
- $RUNNER
environment: $ENVIRONMENT
script:
- >
helm upgrade $RELEASE helm/charts/ -f ./helm/charts/values.yaml
--install
$HELM_ARGS
openshift:prod:
<<: *openshift_template
variables:
HELM_ARGS: >
--set Hosts={host1\,host2\,host3}
It does set the value, it just doesn't get interpreted as a list for some reason.
Just figured this out, although I'm still not 100% sure on the cause.
Basically, when written directly in the template's script (or command line) the commas need to be escaped (e.g. --set hosts={host1\,host2\,host3}
) but when it's in a job variable you can't escape the commas, it needs to be --set hosts={host1,host2,host3}