我有一个Azure多阶段CI / CD管道。它具有测试和UAT部署的阶段。


I can't. Whatever I try, if Test is skipped, UAT is also skipped. Unless I use always(), but then UAT will run even if Test fails.

  - stage: Test
    condition: and(succeeded(), ne(variables['build.sourceBranchName'], 'DoUAT')) # Skip for UAT deployment tests

  - stage: UAT
    condition: and(succeeded(), in(variables['build.sourceBranchName'], 'master', 'DoUAT')) # Only deploy off master branch and branch to test UAT deploys.


What I get vs what I want

  • sunde 回复

    I think it's because the stage doesn't run that it doesn't get a status (eg succeeded, failed, canceled etc.). There is no status function for skipped.

    With that, I think you will need to add a dependency on the stage before Test so that this evaluation can be made. Let's say that stage is called Build.


    # run the stage if build is successful 
    # and test succeeded or skipped 
    # AND the branch is correct
      and(succeeded('Build'), not(failed('Test'))), 
      in(variables['build.sourceBranchName'], 'master', 'DoUAT')
    失败了         工作:         不带参数的情况下,仅当依赖关系图中的任何先前作业失败时,才将其评估为True。   将作业名称作为参数,仅当这些作业中的任何一个失败时,才求值为True。

    Because of this documentation, I think it's necessary to add the Test parameter to target that stage specifically. However, I'm not sure if this necessitates that the Test name be added to the dependencies section of the UAT stage.