1
votes

In Devops in release pipeline, I am configuring variables (name of the resources to be deployed for Dev, preprod stages).Hence under override template parameters, i am specifying -accountName $(accountName) but the name as mentioned in variables (for Dev, preprod) is not accepted, instead it takes the values from template parameters json. Please suggest solution.

2

2 Answers

2
votes

You may try to use ${{ variables.accountName}} instead $(accountName) in the pipeline to pass the parameters to the template. You can set the variable system.debug as true to check the full log of the pipeline. In the last section in InitializePipeline, you can see how the resulting yaml looks. It seems that ${{ }} is evaluated during processing the templates etc. but $() is evaluated later.

0
votes

I had a similar issue as well but a slightly different solution.

My sample azure-pipelines.yml where flag parameter wasn't being overridden in the template.

parameters:
  - name: var1
    type: string
  - name: var2
    type: string
  - name: bool1
    type: bool

...
omitted
...

          - task: AzureResourceManagerTemplateDeployment@3
            inputs:
              deploymentScope: 'Resource Group'
              azureResourceManagerConnection: ''
              subscriptionId: ''
              action: 'Create Or Update Resource Group'
              resourceGroupName: rg-${{parameters.var1}}-${{parameters.var2}}
              location: ''
              templateLocation: 'Linked artifact'
              csmFile: $(System.DefaultWorkingDirectory)/arm.json
              csmParametersFile: $(System.DefaultWorkingDirectory)/arm.parameters.json
              deploymentMode: 'Incremental'
              overrideParameters: >-
                -string1 ${{parameters.var1}}
                -string2 ${{parameters.var2}}
                -flag ${{parameters.bool1}}

The problem was with my overrideParameters block style.
I was using >- which removes all newlines at the end but > works which puts a newline at the end. Learn more here.