如果可能的话,我想要一个 yaml。然而,情况决定了这个单一的 yaml 将自动触发某些分支(开发/发布),但仍然可以由 qa 希望测试的任何其他分支手动构建(即他们想要测试一个功能分支,他们可以构建它)使用此 yaml)。
我需要动态设置 buildconfig 属性。
我有:
trigger:
branches:
include:
- develop
- release/*
- Release/*
pool:
name: 'my-agent'
variables:
isRelease: $[contains(variables['Build.SourceBranch'], 'release')]
if {{$(isRelease)}}:
buildConfiguration: 'Release'
//如果没有发布,则将构建配置设置为“调试
”,但我在语法上遇到了困难。我找不到运行良好的 not
运算符,或者 notIn
...有人可以帮忙解决这个问题吗?
最佳答案
我会否定 if
条件以获得“调试”条件。另外,没有 else
,所以你必须将它们堆叠起来:
${{ if variables.isRelease }}:
buildConfiguration: 'Release'
${{ if not(variables.isRelease) }}:
buildConfiguration: 'NotRelease'
关于azure - If/Else 是否包含在 Azure DevOps YAML 中用于动态设置构建配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66481774/