2021-04-07 18:05:31 -05:00
|
|
|
# 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:
|
2023-02-21 23:00:06 -06:00
|
|
|
- template: .azure-pipelines/cleanup.yml@buildimage
|
2021-10-08 02:31:49 -05:00
|
|
|
- ${{ parameters.preSteps }}
|
2021-04-07 18:05:31 -05:00
|
|
|
- script: |
|
2023-06-05 05:42:06 -05:00
|
|
|
[ -n "$OVERRIDE_BUILD_OPTIONS" ] && OVERRIDE_BUILD_OPTIONS=$(OVERRIDE_BUILD_OPTIONS)
|
|
|
|
BUILD_OPTIONS="$(BUILD_OPTIONS) $OVERRIDE_BUILD_OPTIONS"
|
2022-03-23 09:36:53 -05:00
|
|
|
if [ -n "$(CACHE_MODE)" ] && echo $(PLATFORM_AZP) | grep -E -q "^(vs|broadcom|mellanox|marvell-armhf)$"; then
|
2021-04-08 18:36:53 -05:00
|
|
|
CACHE_OPTIONS="SONIC_DPKG_CACHE_METHOD=$(CACHE_MODE) SONIC_DPKG_CACHE_SOURCE=/nfs/dpkg_cache/$(PLATFORM_AZP)"
|
2023-06-05 05:42:06 -05:00
|
|
|
BUILD_OPTIONS="$BUILD_OPTIONS $CACHE_OPTIONS"
|
2021-04-07 18:05:31 -05:00
|
|
|
fi
|
2023-06-05 05:42:06 -05:00
|
|
|
echo $BUILD_OPTIONS
|
2023-04-06 20:35:02 -05:00
|
|
|
echo "##vso[task.setvariable variable=BUILD_OPTIONS]$BUILD_OPTIONS"
|
2021-04-11 18:43:06 -05:00
|
|
|
displayName: "Set cache options"
|
2021-04-07 18:05:31 -05:00
|
|
|
- checkout: self
|
|
|
|
submodules: recursive
|
2022-12-09 02:12:43 -06:00
|
|
|
fetchDepth: 0
|
2022-10-18 23:26:50 -05:00
|
|
|
condition: and(succeeded(), eq(variables.SKIP_CHECKOUT, ''))
|
2021-04-07 18:05:31 -05:00
|
|
|
displayName: 'Checkout code'
|
|
|
|
- script: |
|
2021-04-22 21:24:00 -05:00
|
|
|
BRANCH_NAME=$(Build.SourceBranchName)
|
|
|
|
[ -n "$SYSTEM_PULLREQUEST_PULLREQUESTID" ] && BRANCH_NAME="$SYSTEM_PULLREQUEST_TARGETBRANCH-$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER"
|
|
|
|
git checkout -b $BRANCH_NAME
|
2021-04-07 18:05:31 -05:00
|
|
|
sudo modprobe overlay
|
|
|
|
sudo apt-get install -y acl
|
|
|
|
sudo bash -c "echo 1 > /proc/sys/vm/compact_memory"
|
2021-07-09 01:51:17 -05:00
|
|
|
ENABLE_DOCKER_BASE_PULL=y make PLATFORM=$(PLATFORM_AZP) PLATFORM_ARCH=$(PLATFORM_ARCH) $(BUILD_OPTIONS) configure
|
2021-04-07 18:05:31 -05:00
|
|
|
displayName: 'Make configure'
|
|
|
|
postSteps:
|
2022-05-30 03:50:06 -05:00
|
|
|
- script: |
|
|
|
|
mkdir -p $(Build.ArtifactStagingDirectory)/target
|
|
|
|
mv target/* $(Build.ArtifactStagingDirectory)/target/
|
2021-04-19 20:17:05 -05:00
|
|
|
displayName: Copy Artifacts
|
2021-11-10 09:15:06 -06:00
|
|
|
condition: always()
|
2021-04-19 20:17:05 -05:00
|
|
|
- publish: $(Build.ArtifactStagingDirectory)
|
2021-04-07 18:05:31 -05:00
|
|
|
artifact: 'sonic-buildimage.$(GROUP_NAME)$(GROUP_EXTNAME)'
|
|
|
|
displayName: "Archive sonic image"
|
2021-11-24 00:10:04 -06:00
|
|
|
- publish: $(Build.ArtifactStagingDirectory)
|
2022-05-30 03:02:27 -05:00
|
|
|
condition: or(failed(), canceled())
|
2021-11-24 00:10:04 -06:00
|
|
|
artifact: 'sonic-buildimage.$(GROUP_NAME)$(GROUP_EXTNAME)$(System.JobAttempt)'
|
|
|
|
displayName: "Archive failed sonic image"
|
2022-05-20 01:32:53 -05:00
|
|
|
- ${{ 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)'
|
2021-04-07 18:05:31 -05:00
|
|
|
- ${{ parameters.postSteps }}
|
2023-02-21 23:00:06 -06:00
|
|
|
- template: .azure-pipelines/cleanup.yml@buildimage
|
2021-04-07 18:05:31 -05:00
|
|
|
jobGroups: ${{ parameters.jobGroups }}
|
|
|
|
buildSteps: ${{ parameters.buildSteps }}
|