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.
DeployAndTest
stage it cannot be cancelled manually or due to new push to branch when it runs as part of a pull request build?You can add the condition "always()
" to the stages and jobs that you want to be noncancellable.
For example:
stages:
- stage: A
displayName: 'Stage A'
jobs:
- job: A1
displayName: 'Job A1'
. . .
- job: A2
displayName: 'Job A2'
dependsOn: A1
condition: always()
. . .
- stage: B
displayName: 'Stage B'
dependsOn: A
condition: always()
jobs:
- job: B1
displayName: 'Job B1'
. . .
- job: B2
displayName: 'Job B2'
dependsOn: B1
. . .
Stage A
is running, if cancel it, Job A2
and Stage B
will still run.Job A2
and Stage B
will still run.