简体   繁体   English

azure 管道中部署作业的条件批准门

[英]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.我不明白为什么它要求批准。

  1. Are approval executed first for a stage before jobs conditions are evaluated?在评估工作条件之前,是否首先对某个阶段执行审批?
  2. Did i miss something in the yaml?我是否错过了 yaml 中的某些内容?

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另一个问题是我们可以根据变量组中的变量值有条件地插入阶段模板吗

  • stages ${{ifeq(variables['Policy_Approval_Required'],'true')}}:阶段 ${{ifeq(variables['Policy_Approval_Required'],'true')}}:

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.

相关问题 azure 管道中管道作业的有条件批准 - Conditional Approval in pipeline jobs in azure pipelines 是否可以结合使用许可和批准来限制Azure部署? - Is it possible to combine a gate and an approval to limit an Azure deployment? azure管道中部署作业的批准信息 - Approval information on deployment job in azure pipelines 针对 Azure 应用服务配置 Azure 管道部署阶段的批准 - Configure approval for Azure Pipelines deployment stage against Azure App Services 在 Azure Pipelines 部署作业之间传递变量 - Pass variable between Azure Pipelines deployment jobs 使用 azure devops 部署 ADF 是否会影响环境中的现有管道/作业 - Will ADF deployment using azure devops affect existing Pipelines/Jobs in the environment Azure 数据块和 ADF 部署对运行作业/管道的影响 - Impact of Azure databricks and ADF deployment to running jobs/pipelines Azure Devops 部署批准 - Azure Devops Deployment Approval 将 Azure 数据工厂管道有条件地部署到另一个资源组 - Conditional deployment of Azure Data Factory pipelines to another resource group 用于并行应用部署的 Azure DevOps 审批门 - Azure DevOps Approval Gate For Parallel App Deployments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM