Reputation: 1910
In Azure Devops I am using the template yaml loop-template.yml:
parameters:
paths: string
steps :
- ${{ each path in split(parameters.paths, ',') }}:
- script: echo "loop template " ${{ path }}
displayName: ScriptName ${{ path }}
which gets a comma-delimited string with paths and tries to iterate through them.
I call this template from another yaml which is like this
variables:
- name: SnykScanPaths
value: val1,val2
# it doesn't work
- template: loop-template.yml
parameters:
paths : $(SnykScanPaths)
# it works
- template: loop-template.yml
parameters:
paths : ${{variables.SnykScanPaths}}
The results I get are the following
So even though the compile time variable ${{variables.SnykScanPaths}} has the same value with run time variable $(SnykScanPaths), only the compile time variable leads to proper iteration.
Any idea what can I do with this? thanks for the help.
Upvotes: 1
Views: 370
Reputation: 7241
This is expected.
You must use ${{}} as the structure to get the value, if you use $(), the entire string will be recognized as string by default.
Parameters are expanded just before the pipeline runs so that values surrounded by ${{ }} are replaced with parameter values.
So simply put, your first type of usage is not correct.
Upvotes: 1