[英]Conditional Approval gate in deployment jobs in azure pipelines
Since conditional approval doesn't work in azure yaml pipeline i've been trying a workaround using 2 environment in deployment stage, shown in yaml.由于有条件批准在 azure yaml 管道中不起作用,我一直在尝试在部署阶段使用 2 个环境的解决方法,如 yaml 所示。 using a conditions in job and a variable i want to check if approval required or not but when i run the pipeline, i see its still asking for approval even though the condition is not satisfied for the deployment job that requires approval.
使用作业中的条件和变量我想检查是否需要批准但是当我运行管道时,我看到它仍然要求批准,即使条件不满足需要批准的部署作业。 Post approval though the job that required approval skips as expected.
尽管需要批准的作业按预期跳过,但发布批准。 I dont understand why its asking for approval.
我不明白为什么它要求批准。
trigger:
- none
variables:
- group: pipelinevariables
# Agent VM image name
- name: vmImageName
value: 'ubuntu-latest'
stages:
- stage: Deploy
displayName: Deploy stage
jobs:
- deployment: DeployWebWithoutApprval
displayName: deploy Web App without approval
condition: and(succeeded(),ne(variables.DEV_APPROVAL_REQUIRED,'true'))
pool:
vmImage: $(vmImageName)
# creates an environment if it doesn't exist
environment: 'app-dev'
strategy:
runOnce:
deploy:
steps:
- script: echo No approval
- deployment: DeployWebWithApprval
displayName: deploy Web App with approval
dependsOn: DeployWebWithoutApprval
condition: and(eq(dependencies.DeployWebWithoutApprval.result,'Skipped'),eq(variables.DEV_APPROVAL_REQUIRED,'true'))
pool:
vmImage: $(vmImageName)
# creates an environment if it doesn't exist
environment: 'app-dev-with-approval'
strategy:
runOnce:
deploy:
steps:
- script: echo requires approval
update: this works if i define 2 stages and and same set of conditions but that would show 2 stages in build details page which we don't want更新:如果我定义了 2 个阶段和相同的一组条件,则此方法有效,但这将在构建详细信息页面中显示我们不想要的 2 个阶段
Another question is Can we conditionally insert stage template based on variable value from variable group另一个问题是我们可以根据变量组中的变量值有条件地插入阶段模板吗
Insert template conditionally is supported, you can check the following link: https://github.com/microsoft/azure-pipelines-agent/issues/1749 .支持有条件插入模板,您可以查看以下链接: https://github.com/microsoft/azure-pipelines-agent/issues/1749 。 Check the following example:
检查以下示例:
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- template: sharedstep.yml@templates
parameters:
value: true
I have had the exact same issue with approval gates and conditions.我在审批门和条件方面遇到了完全相同的问题。 It is unfortunately not supported as of yet, but it's reported to Microsoft ( here ).
遗憾的是,目前尚不支持它,但已向 Microsoft 报告( 此处)。 There is also this issue.
还有这个问题。 Seems like an issue with the order of evaluating approvals vs conditions.
似乎是评估批准与条件的顺序问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.