I have a Azure DevOps YAML Pipeline which has multiple deploy stages and I want to template the stages and add these using a for-each template loop, this is what I have so far
parameters:
- name: Deployments
type: object
default:
Deployment:
name: DeployDev
displayName: ...
dependsOn: ...
environment: ...
...
stages:
- stage: SomeOtherStage
...
- ${{ each deployment in parameters.Deployments }}
- template: ./path/to/template/file.yml
parameters:
name: ${{ deployment.name }}
displayName: ...
...
And in my stage template
parameters:
- name: name
type: string
- name: displayName
...
stages:
- stage: ${{ parameters.name }}
displayName: ${{ parameters.displayName }}
...
My issue is that when I get this into Azure DevOps and validate the pipeline I get the validation error /azure-pipelines-cd.yml: (Line: 36, Col: 15, Idx: 685) - (Line: 36, Col: 15, Idx: 685): Mapping values are not allowed in this context.
.
I have seen examples of this done elsewhere but cannot see why I am getting this error, has anyone else done this and got it working