【发布时间】:2020-06-01 15:35:54
【问题描述】:
我想对作为参数传递的字符串数组执行一些操作(发布)。 问题是,这个参数是动态的:
# pipeline.yml
- job: MyJob
pool:
[...]
steps:
- pwsh: |
$affected = ['app-one', 'app-two'] # Here I hardcoded the array but in my real code this is set dynamically
Write-Host "##vso[task.setvariable variable=affected;isOutput=true]$affected"
name: setAffected
displayName: 'Settings affected'
- template: ./build.yml
parameters:
affected: $[ dependencies.Affected.outputs['setAffected.affected'] ] # Here I pass the array of string to the template
# build.yml
parameters:
affected: ''
jobs:
- job: Build
condition: succeeded('Affected')
dependsOn: Affected
pool:
[...]
variables:
affected: ${{ parameters.affected }}
steps:
- ${{each app in $(affected)}}:
- pwsh: |
Write-Host "${{app}}"
- ${{each app in parameters.affected}}:
- pwsh: |
Write-Host "${{app}}"
${{each app in $(affected)}} 或 ${{each app in parameters.affected}} 都不起作用...
我怎样才能设法对我的每个数组项执行一些操作?
谢谢
【问题讨论】:
-
让我猜猜。你想运行像 Nx 这样的 mororepo 应用程序吗?我有点想做同样的事情
标签: azure-devops yaml