I'm struggling with the syntax of the each keyword in YAML templates.
Essentially, I'm passing a list of jobs to a template. The template should execute those jobs, filtering out unwanted variable groups.
template.yml:
parameters:
- name: DeployJobs
type: jobList
jobs:
- ${{ each job in parameters.DeployJobs }}:
${{ if job.variables }}:
variables:
- ${{ each var in job.variables }}:
- ${{ each pair in var }}:
${{ if ne(pair.value, 'var-group-blue') }}:
- group: ${{ pair.value }}
azure-pipelines.yml:
jobs:
- template: template.yml
parameters:
DeployJobs:
- deployment: mydeployjob
variables:
- group: var-group-blue # the template should filter out this var group
- group: var-group-green
...
But I'm getting the compilation errors Expected a mapping and Object reference not set to an instance of an object. on the line:
- group: ${{ pair.value }}
Can anyone offer advice on what syntax or indenting that I may be missing?