首页 > 解决方案 > Azure 管道,最后阶段被跳过,我不明白为什么!是否有审批限制或时间限制?

问题描述

我正在研究在 Windows 自托管代理上运行的管道。我在 Stage1 中使用一个脚本来初始化一个变量,我在 Stage2 和 Stage3 的条件中使用该变量。

如果 variable 为 true,则运行 Stage2,此阶段作为具有批准的环境。如果变量为假,则运行 Stage3 阶段。

在任何情况下,都会运行 Stage4。这现在效果很好,但如果运行 Stage2,Stage5 总是会被跳过!

在此处输入图像描述

我不明白为什么 Stage5 的唯一依赖项是 Stage4 !

stages:
  - stage: Build
    jobs:
      - job: CompareFiles
        dependsOn: Build_Project
        steps:
          - checkout: none
          - task: PowerShell@2
            name: compareFiles
            inputs:
              targetType: filePath
              filePath: '***\compareFileContent.ps1'

  - stage: ContinueWithApproval
    dependsOn: Build
    condition: eq( dependencies.Build.outputs['CompareFiles.compareFiles.filesAreEqual'], 'true' )
    jobs:
    - deployment: Continue
      environment: 'EnvironmentWithApproval'
      strategy:
        runOnce:
          deploy:
            steps:
            - task: CmdLine@2
              inputs:
                script: '***'

  - stage: ContinueWithoutApproval
    dependsOn: Build
    condition: eq( dependencies.Build.outputs['CompareFiles.compareFiles.filesAreEqual'], 'false' )
    jobs:
    - deployment: Continue
      environment: 'EnvironmentWithoutApproval'
      strategy:
        runOnce:
          deploy:
            steps:
            - task: CmdLine@2
              inputs:
                script: '***'


  - stage: DeployStaging
    dependsOn: 
    - ContinueWithApproval
    - ContinueWithoutApproval
    condition: or(eq( dependencies.ContinueWithApproval.result, 'Succeeded' ), eq( dependencies.ContinueWithoutApproval.result, 'Succeeded' ))
    jobs:
    - deployment: Deploy_To_Staging
      environment: 'Name ST'
      strategy:
           runOnce:
             deploy:
               steps:
                - task: PowerShell@2
                  inputs:
                    targetType: filePath
                    filePath: '***.ps1'

  - stage: DeployPreProd
    dependsOn: 
    - DeployStaging
    jobs:
    - deployment: Deploy_To_Preprod
      environment: 'Name PP'
      strategy:
           runOnce:
             deploy:
               steps:
                - task: PowerShell@2
                  inputs:
                    targetType: filePath
                    filePath: '***.ps1'

如果变量为假,则运行 Stage3,然后运行 ​​Stage4 和 Stage5 !!!

哦!Stage5的环境也有审批,会不会是这个问题?批准数量的限制 ?

谢谢和问候,克劳德

标签: azure-pipelinesazure-pipelines-yaml

解决方案


Approvals are on environment so this should not be an issue.

Try removing

dependsOn: 
- DeployStaging

From your 5th stage. The default behavior is to depend on the previous stage. I am wondering since dependsOn is being provided w/o a condition it is not skipping since the condition has not been provided.

Alternatively could add

succeeded()

推荐阅读