I am trying to put a variable inside a parameter in the pipeline yml for the Azure DevOps. I am trying to do it like so:
variables:
myArg: true
- template: my-custom-template.yml@myrep
parameters:
myArg: $[ eq(variables.argVal, 'true') ]
But I am getting the error:
$[ eq(variables.argVal, 'true') ]
Cannot process argument transformation on parameter | 'myArg'. Cannot convert value "System.String" to type | "System.Boolean". Boolean parameters accept only Boolean values and | numbers, such as $True, $False, 1 or 0.
Instead of the $[ eq(variables.argVal, 'true') ]
I tried the ${{ eq(variables.argVal, 'true') }}
and the $( eq(variables.argVal, 'true') )
. All gave the same error.
So, could someone help me to understand what is the correct way to convert a variable to a boolean parameter in Azure DevOps pipeline yml, please?
You can't use parameters with runtime expressions ($[]
). Parameters are resolved at template compilation time, before runtime expressions can be evaluated. You should use compilation expressions, ${{}}