Is there a way to make an azure pipeline stage or job noncancellable?
Description:
We have a pipeline in the lines of:
stages:
- stage: BuildAndUnitTest
.........
.........
- stage: DeployAndTest // deploys to a shared resource and runs tests against it
lockBehavior: sequential
jobs:
- job: DeployInfrastructureUsingPulumi
.........
.........
- job: RunTestsAndCleanUp
.........
.........
- job: DestroyInfrastructureUsingPulumi
.........
.........
In the pipeline note that DeployAndTest
stage makes changes to a shared resource. It deploys cloud infrastructure, runs some tests then destroy the infrastructure.
The next run should take place only after the clean and destroy are finished.
- Is there a way to ensure once the pipeline enters the
DeployAndTest
stage it cannot be cancelled manually or due to new push to branch when it runs as part of a pull request build? - Or is there a better technique to achieve this kind of pipeline run?
You can add the condition "
always()
" to the stages and jobs that you want to be noncancellable.For example:
Stage A
is running, if cancel it,Job A2
andStage B
will still run.Job A2
andStage B
will still run.