2bf2e02719
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.
72 lines
2.8 KiB
YAML
72 lines
2.8 KiB
YAML
# The azure pipeline template for PR build, Official build, and upgrade version build
|
|
|
|
parameters:
|
|
- name: 'jobFilters'
|
|
type: object
|
|
default: ''
|
|
- name: 'preSteps'
|
|
type: stepList
|
|
default: []
|
|
- name: 'buildSteps'
|
|
type: stepList
|
|
default: []
|
|
- name: 'postSteps'
|
|
type: stepList
|
|
default: []
|
|
- name: jobGroups
|
|
type: object
|
|
default: []
|
|
- name: jobVariables
|
|
type: object
|
|
default: []
|
|
jobs:
|
|
- template: azure-pipelines-job-groups.yml
|
|
parameters:
|
|
jobFilters: ${{ parameters.jobFilters }}
|
|
jobVariables: ${{ parameters.jobVariables }}
|
|
preSteps:
|
|
- template: cleanup.yml
|
|
- ${{ parameters.preSteps }}
|
|
- script: |
|
|
if [ -n "$(CACHE_MODE)" ] && echo $(PLATFORM_AZP) | grep -E -q "^(vs|broadcom|mellanox|marvell-armhf)$"; then
|
|
CACHE_OPTIONS="SONIC_DPKG_CACHE_METHOD=$(CACHE_MODE) SONIC_DPKG_CACHE_SOURCE=/nfs/dpkg_cache/$(PLATFORM_AZP)"
|
|
BUILD_OPTIONS="$(BUILD_OPTIONS) $CACHE_OPTIONS"
|
|
echo "##vso[task.setvariable variable=BUILD_OPTIONS]$BUILD_OPTIONS"
|
|
fi
|
|
displayName: "Set cache options"
|
|
- checkout: self
|
|
submodules: recursive
|
|
condition: and(succeeded(), eq(variables.SKIP_CHECKOUT, ''))
|
|
displayName: 'Checkout code'
|
|
- script: |
|
|
BRANCH_NAME=$(Build.SourceBranchName)
|
|
[ -n "$SYSTEM_PULLREQUEST_PULLREQUESTID" ] && BRANCH_NAME="$SYSTEM_PULLREQUEST_TARGETBRANCH-$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER"
|
|
git checkout -b $BRANCH_NAME
|
|
sudo modprobe overlay
|
|
sudo apt-get install -y acl
|
|
sudo bash -c "echo 1 > /proc/sys/vm/compact_memory"
|
|
ENABLE_DOCKER_BASE_PULL=y make PLATFORM=$(PLATFORM_AZP) PLATFORM_ARCH=$(PLATFORM_ARCH) $(BUILD_OPTIONS) configure
|
|
displayName: 'Make configure'
|
|
postSteps:
|
|
- script: |
|
|
mkdir -p $(Build.ArtifactStagingDirectory)/target
|
|
mv target/* $(Build.ArtifactStagingDirectory)/target/
|
|
displayName: Copy Artifacts
|
|
condition: always()
|
|
- publish: $(Build.ArtifactStagingDirectory)
|
|
artifact: 'sonic-buildimage.$(GROUP_NAME)$(GROUP_EXTNAME)'
|
|
displayName: "Archive sonic image"
|
|
- publish: $(Build.ArtifactStagingDirectory)
|
|
condition: or(failed(), canceled())
|
|
artifact: 'sonic-buildimage.$(GROUP_NAME)$(GROUP_EXTNAME)$(System.JobAttempt)'
|
|
displayName: "Archive failed sonic image"
|
|
- ${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
|
|
- template: trigger-publish-artifacts-build.yml
|
|
parameters:
|
|
artifactName: 'sonic-buildimage.$(GROUP_NAME)$(GROUP_EXTNAME)'
|
|
publishPrefix: '$(Build.DefinitionName)/$(Build.SourceBranchName)/$(GROUP_NAME)'
|
|
- ${{ parameters.postSteps }}
|
|
- template: cleanup.yml
|
|
jobGroups: ${{ parameters.jobGroups }}
|
|
buildSteps: ${{ parameters.buildSteps }}
|