我遇到了一个问题,我试图在 stage
condition
在纯文本中,它应该像这样工作:
(branch is release AND var undefined) OR (branch is release AND var == sys)
我在 YAML 中尝试这样做的方式是这样的:
# SYS
- stage: BuildSYS
condition: or(and(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), eq('[variables.Env]', '')), and(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), eq('[variables.Env]', 'SYS')))
jobs:
- job:
steps:
- script: echo Hi form SYS!
Env
在这种情况下是我传递到管道中的变量。
触发时我在 release/*
分支上,所以我不确定我做错了什么。
答案 0 :(得分:1)
这里 '[variables.Env]'
是问题所在。请将其替换为 variables['Env']
。
所以你的条件应该是:
condition: or(and(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), eq(variables['Env'], '')), and(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), eq(variables['Env'], 'SYS')))