【发布时间】:2020-03-17 20:10:51
【问题描述】:
变量支持的一致性和语法在 Azure DevOps YAML 中差异很大。 举个例子:
trigger:
- master
# Variable Group has $(testCategory1) with value
# 'TestCategory=bvttestonly | TestCategory=logintest'
variables:
- group: DYNAMIC_VG
jobs:
- job:
pool: 'MyPool' #Has about 10+ self hosted agents
strategy:
parallel: $[ variables['noOfVMsDynamic']]
variables:
indyx: '$(testCategories$(System.JobPositionInPhase))'
indyx2: $[ variables['indyx'] ]
testCategories: $[ variables[ 'indyx2' ] ]
steps:
- script: |
echo "indyx2 - $(indyx2)"
echo "testCategories $(testCategories)"
displayName: 'Display Test Categories'
步骤打印:
"indyx2 - $(testCategories1)"
"testCategories $(testCategories1)"
我需要打印变量组中定义的 $(testCategories1) 的值:
'TestCategory=bvttestonly | TestCategory=logintest'
【问题讨论】:
-
你试过
indyx: $[ variables[format('{0}{1}', 'testCategories', variables['System.JobPositionInPhase'])] ]吗?现在无法真正测试这个,所以作为评论发布,您可能需要将.更改为其他内容 -
@Luizgrs:我会尝试并告诉你。
-
解决方法:使用动态矩阵策略和在运行时创建的 JSON。参考stackoverflow.com/questions/59076036/…
标签: azure azure-devops azure-devops-yaml