我有一个自托管虚拟机池(MyTestPool),其中一半专用于安装和测试“开启”构建(打开的功能很少)和“关闭”构建(这是默认安装)。我所有的测试代理虚拟机都具有“全部”作为用户定义的功能。其中一半也被标记为“开”,另一半被标记为“关”。
现在我有两个称为 DEPLOYOFF 和 DEPLOYON 的阶段,如果变量组变量“skipDeployOffStage”或“skipDeployOnStage”设置为 true,则可以跳过这些阶段。如果只测试 ON/OFF,我想做的是使用“ALL”作为代理需求。如果要同时测试 ON 和 OFF,则适当的阶段将要求它们各自的“ON”或“OFF”VM。
问题:${{ if }} 不起作用。
trigger: none
pr: none
pool: 'MyBuildPool'
variables:
- group: TEST_IF_VARIABLE_GROUP
- name: subPool
value: 'ON'
- name: useAllPool
value: $[ or(eq( variables.skipDeployOnStage, true), eq( variables.skipDeployOffStage, true)) ]
stages:
- stage: DEPLOYOFF
condition: ne(variables['skipDeployOffStage'], 'true')
variables:
# The test stage's subpool
${{ if variables.useAllPool }}:
subPool: 'ALL'
${{ if not(variables.useAllPool) }}:
subPool: 'OFF'
pool:
name: 'MyTestPool'
demands:
- ${{ variables.subPool }}
jobs:
- job:
steps:
- checkout: none
- pwsh: |
Write-Host ("Value of useAllPool is: {0}" -f '$(useAllPool)')
Write-Host ("Value of VG variable 'skipDeployOnStage' is {0} and 'skipDeployOffStage' is {1}" -f '$(skipDeployOnStage)', '$(skipDeployOffStage)')
Write-Host ("Subpool is {0}" -f '$(subPool)')
displayName: 'Determined SubPool'
标志之一为假时的输出:
2020-08-02T18:39:05.5849160Z Value of useAllPool is: True
2020-08-02T18:39:05.5854283Z Value of VG variable 'skipDeployOnStage' is true and 'skipDeployOffStage' is false
2020-08-02T18:39:05.5868711Z Subpool is ALL
两者都为假时的输出:
2020-08-02T18:56:40.5371875Z Value of useAllPool is: False
2020-08-02T18:56:40.5383258Z Value of VG variable 'skipDeployOnStage' is false and 'skipDeployOffStage' is false
2020-08-02T18:56:40.5386626Z Subpool is ALL
我错过了什么?