Is there any way to use nested within parameters on azure-pipelines.yml?
The example below is wrong...
# my-template.yml
parameters:
steps:
- ${{ each pf in parameters.pf }}:
- task: PublishBuildArtifacts@1
displayName: 'Publish ${{ pf.rid }} ${{ pf.output }}'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/${{ pf.output }}.zip'
# azure-pipelines.yml
steps:
- template: my-template.yml
parameters:
- windows:
rid: 'win-x64'
output: 'Foo.exe'
- macos:
rid: 'osx-x64'
output: 'foo'
I tweaked your example a little bit to make it work:
# my-template.yml
parameters:
pf: []
steps:
- ${{ each pf in parameters.pf }}:
- script: echo ${{ pf.rid }} ${{ pf.output }}
displayName: 'Publish ${{ pf.rid }} ${{ pf.output }}'
# azure-pipelines.yml
steps:
- template: my-template.yml
parameters:
pf:
# windows
- rid: 'win-x64'
output: 'Foo.exe'
# macos
- rid: 'osx-x64'
output: 'foo'
You could find more information here about templates iterative insertion.
Although I suspect what you want to do could be better achieved using strategy and matrix like the following:
# azure-pipelines.yml
strategy:
matrix:
windows:
imageName: "vs2017-win2016"
output: 'Foo.exe'
macos:
imageName: 'macos-10.13'
output: 'foo'
pool:
vmImage: $(imageName)
steps:
- script: echo $(output)
displayName: 'Publish'
You could find more information here about build across multiple platforms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With