Multiline overrideValues Helm install Azure DevOps

Viewed 1507

Is it possible to specify the values to be overridden in the HelmDeploy task in Azure devOps pipelines? For example, something like the task below (which obviously does not work exactly as is):

  - task: HelmDeploy@0
              displayName: 'helm install'
              inputs:
                connectionType: 'Azure Resource Manager'
                azureSubscription: '$(RM_SERVICE_CONNECTION_NAME)'
                azureResourceGroup: '$(AKS_RESOURCE_GROUP)'
                kubernetesCluster: '$(AKS_NAME)'
                namespace: '$(AKS_NAMESPACE)'
                command: 'install'
                chartType: 'FilePath'
                chartPath: '$(deploymentChartName)'
                releaseName: test-release
                overrideValues: |
                  value1='value_1'
                  value2='value_2'                 

Is there any formatting similar to the above example that would work?

2 Answers

I am afraid overrideValues field cannot accept multiline override variables. As the document says multiple values should be separating values with commas key1=val1,key2=val2.

However, you can have a try using the arguments field and pass the variables.

See below:

  - task: HelmDeploy@0
    displayName: 'helm install'
    inputs:
       connectionType: 'Azure Resource Manager'
       azureSubscription: '$(RM_SERVICE_CONNECTION_NAME)'
       ...
       ...
       arguments: >
          --set foo=bar
          --set foo1=bar1
          --set foo2=bar2

In fact, the syntax as in this question works out exactly like that. The new lines are joined with a comma.

It is also stated as such in the documentation.

(Optional) Set values on the command line. You can specify multiple values by separating values with commas. For example, key1=val1,key2=val2. You can also specify multiple values by delimiting them with newline as so:
key1=val1
key2=val2
Please note that if you have a value which itself contains newlines, use the valueFile option, else the task will treat the newline as a delimiter. The task will construct the helm command by using these set values. For example, helm install --set key1=val1 ./redis

I am using this syntax for all my pipelines and its working out as expected.

overrideValues: |
    value1='value_1'
    value2='value_2'

The reason we use the pipe here is that we want to preserve the new lines. This standard yaml syntax is documented here.

Block Style Indicator: The block style indicates how newlines inside the block should behave. If you would like them to be kept as newlines, use the literal style, indicated by a pipe (|). If instead you want them to be replaced by spaces, use the folded style, indicated by a right angle bracket (>). (To get a newline using the folded style, leave a blank line by putting two newlines in. Lines with extra indentation are also not folded.)

Back to the values, if a single value contains a new line as stated in the docs or a whitespace from my own experience, then things become problematic. The suggested approach here is to use a values files.

Related