From 8e7a491f3bbbf00f551fb0aa581d422f35a2533f Mon Sep 17 00:00:00 2001 From: Ye Jianquan Date: Wed, 19 Oct 2022 12:26:50 +0800 Subject: [PATCH] Enable to cancel pipeline jobs during checkout code and tests (#12436) co-authorized by: jianquanye@microsoft.com 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. --- .azure-pipelines/azure-pipelines-image-template.yml | 2 +- azure-pipelines.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/azure-pipelines-image-template.yml b/.azure-pipelines/azure-pipelines-image-template.yml index 0d8d75f6b7..3f34274e49 100644 --- a/.azure-pipelines/azure-pipelines-image-template.yml +++ b/.azure-pipelines/azure-pipelines-image-template.yml @@ -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) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e3b04eaac0..190cdcd444 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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