gpt4 book ai didi

Azure 管道 - 阶段条件取决于

转载 作者:行者123 更新时间:2023-12-05 04:39:39 27 4
gpt4 key购买 nike

我有三个环境:dev、hml 和 qa。

在我的管道中,根据分支,阶段有一个条件来检查它是否会运行:

- stage: Project_Deploy_DEV
condition: eq(variables['Build.SourceBranch'], 'refs/heads/dev')
dependsOn: Project_Build

- stage: Project_Deploy_HML
condition: eq(variables['Build.SourceBranch'], 'refs/heads/hml')
dependsOn: Project_Build

我正在做qa阶段,我想设置一个条件,根据分支,dependon参数会改变:

- stage: Project_QA
condition:
${{ if eq(variables['Build.SourceBranchName'], 'dev') }}:
dependsOn: 'Project_Deploy_DEV'
${{ if eq(variables['Build.SourceBranchName'], 'hml') }}:
dependsOn: 'Project_Deploy_HML'

但是,上述条件不起作用,有人知道执行此条件的最佳方法吗?

谢谢

最佳答案

从您的 YAML 示例来看,似乎存在格式问题。使用if表达式时,不需要在YAML中添加条件字段。

您可以尝试以下示例并检查它是否可以工作。

stages:
- stage: A
jobs:
- job: test
steps:
- xxx

- stage: B
jobs:
- job: test
steps:
- xxx
- stage: C
${{ if eq(variables['Build.SourceBranchName'], 'main') }}:
dependsOn: A
${{ if eq(variables['Build.SourceBranchName'], 'dev') }}:
dependsOn: B
jobs:
- job: test
steps:
- xxx

关于Azure 管道 - 阶段条件取决于,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70406488/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com