有没有办法使用管道(仪表板)中定义的变量在 YAML 模板上使用条件插入来执行步骤:
我的意思是我有这个步骤:
- ${{ if eq(variables.['somevar'], '')}}:
- task: Bash@3
displayName: Var does not being declared
inputs:
targetType: 'inline'
script: |
echo "This is a step where the var 'somevar' does not being declared'
- task: Bash@3
displayName: Another Step
inputs:
targetType: 'inline'
script: |
echo "This is another step where the var 'somevar' does not being declared'
这应该在未声明变量时运行
- ${{ if ne(variables.['somevar'], '')}}:
- task: Bash@3
displayName: Var is being declared
inputs:
targetType: 'inline'
script: |
echo "This is a step where the var 'somevar' is being declared with some value'
- task: Bash@3
displayName: Another Step
inputs:
targetType: 'inline'
script: |
echo "This is another step where the var 'somevar' is being declared with some value'
这应该在声明变量时运行
我知道它存在运行时参数,但我不想每次运行管道(手动)时都使用它们。我希望一些管道在我声明变量时运行一些步骤,而其他一些管道不'当变量没有被声明时,不要运行一些步骤。
我也知道它存在每一步里面的条件,比如
condition: eq(variables.somevar, 'value')
但我想在某些情况下使用条件插入来运行,如上面示例中的许多步骤。不止一步