【问题标题】:Azure Pipelines Stage Condition with Variable带有变量的 Azure Pipelines 阶段条件
【发布时间】:2021-09-12 18:27:35
【问题描述】:

我遇到了一个问题,我试图在 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/* 分支上,所以我不确定自己做错了什么。

【问题讨论】:

    标签: azure-devops continuous-integration yaml azure-pipelines


    【解决方案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')))
    

    【讨论】:

      猜你喜欢
      • 2021-03-20
      • 1970-01-01
      • 2020-06-02
      • 2020-12-02
      • 2021-02-10
      • 2022-09-23
      • 2020-06-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多