我有一个 Azure 多阶段 CI/CD 管道。它具有测试和 UAT 部署阶段。
我希望 UAT 版本在测试成功或被跳过时运行,但如果失败则不运行。
我不能。无论我尝试什么,如果跳过测试,也会跳过 UAT。除非我使用 always()
,否则即使测试失败,UAT 也会运行。
...
- 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.
...
如何跳过一个阶段而不是下一个阶段?
最佳答案
您可以使用 not(failed('Test'))
条件,请尝试以下条件。
- stage: UAT
condition: and(not(failed('Test')), in(variables['build.sourceBranchName'], 'master', DoUAT')) # Only deploy off master branch and branch to test UAT deploys.
...
我测试过并且有效,请查看以下屏幕截图。
关于azure-devops - Azure 多级管道 : conditionally skip one stage but not the next,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60218455/