Skip to content

Commit

Permalink
Enable to cancel pipeline jobs during checkout code and tests (#12436)
Browse files Browse the repository at this point in the history
co-authorized by: [email protected]

Why I did it
Now, checkout code step and KVM test job can't be cancelled even though the whole build is cancelled.
That's because by using Azure Pipeline Conditions, we customized the running condition, and we need to react to the Cancel action explicitly by asserting 'succeeded'
https://learn.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#succeeded
https://learn.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml#ive-got-a-conditional-step-that-runs-even-when-a-job-is-canceled-how-do-i-manage-to-cancel-all-jobs-at-once

How I did it
Assert 'succeeded' condition explicitly.

How to verify it
Verified by cancelling and rerunning the azure pipeline.
  • Loading branch information
yejianquan authored and qiluo-msft committed Oct 19, 2022
1 parent 1999d9a commit 8e7a491
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/azure-pipelines-image-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
displayName: "Set cache options"
- checkout: self
submodules: recursive
condition: eq(variables.SKIP_CHECKOUT, '')
condition: and(succeeded(), eq(variables.SKIP_CHECKOUT, ''))
displayName: 'Checkout code'
- script: |
BRANCH_NAME=$(Build.SourceBranchName)
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ stages:

- stage: Test
dependsOn: BuildVS
condition: and(ne(stageDependencies.BuildVS.outputs['vs.SetVar.SKIP_VSTEST'], 'YES'), in(dependencies.BuildVS.result, 'Succeeded', 'SucceededWithIssues'))
condition: and(succeeded(), and(ne(stageDependencies.BuildVS.outputs['vs.SetVar.SKIP_VSTEST'], 'YES'), in(dependencies.BuildVS.result, 'Succeeded', 'SucceededWithIssues')))
variables:
- name: inventory
value: veos_vtb
Expand Down

0 comments on commit 8e7a491

Please sign in to comment.