有什么方法可以使用parameters
上azure-pipelines.yml
内的嵌套?
下面的示例是错误的...
# 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'
答案 0 :(得分:0)
我对您的示例进行了一些微调以使其起作用:
# 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'
您可以找到有关模板迭代插入的更多信息here。
尽管我怀疑使用strategy
和matrix
可以更好地实现您想要的工作,如下所示:
# 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'
您可以找到关于跨多个平台构建的更多信息here。