33# Add steps that build, run tests, deploy, and more:
44# https://aka.ms/yaml
55# Build and push sonic-slave-[buster|jessie|stretch] images for amd64/armhf/arm64
6+ resources :
7+ repositories :
8+ - repository : buildimage
9+ type : github
10+ name : sonic-net/sonic-buildimage
11+ ref : master
12+ endpoint : sonic-net
613
714schedules :
8- - cron : " 0 8 * * *"
15+ - cron : " 0 0 * * 0"
16+ displayName : Weekly build
917 branches :
1018 include :
11- - 202012
19+ - master
20+ - 202???
1221 always : true
1322
14- trigger : none
15- pr :
23+ pr : none
24+ trigger :
25+ batch : true
1626 branches :
1727 include :
1828 - master
29+ - 202???
1930 paths :
2031 include :
21- - sonic-slave-jessie
22- - sonic-slave-stretch
23- - sonic-slave-buster
32+ - sonic-slave-*
2433 - src/sonic-build-hooks
34+ - files/build/versions
35+ - Makefile
36+ - Makefile.work
2537
2638parameters :
2739- name : ' arches'
@@ -43,70 +55,27 @@ parameters:
4355 type : string
4456 default : sonicdev
4557
46- variables :
47- - ${{ if eq(variables['Build.SourceBranchName'], '202012') }} :
48- - name : BUILD_OPTIONS
49- value : ' SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web,git,docker'
50-
5158stages :
5259- stage : Build
5360 jobs :
5461 - ${{ each dist in parameters.dists }} :
5562 - ${{ if endswith(variables['Build.DefinitionName'], dist) }} :
5663 - ${{ each arch in parameters.arches }} :
57- - job : Build_${{ dist }}_${{ arch }}
58- timeoutInMinutes : 360
59- pool : sonicbld
60- steps :
61- - template : cleanup.yml
62- - checkout : self
63- clean : true
64- submodules : recursive
65- - bash : |
66- set -ex
67-
68- containers=$(docker container ls | grep "sonic-slave" | awk '{ print $1 }')
69- if [ ! -z "$containers" ]; then
70- docker container kill $containers || true
71- sleep 5
72- fi
73- images=$(docker images 'sonic-slave-*' -a -q)
74- if [ ! -z "$images" ]; then
75- docker rmi -f $images
76- fi
77-
78- SLAVE_DIR=sonic-slave-${{ dist }}
79- if [ x${{ arch }} == x"amd64" ]; then
80- SLAVE_BASE_IMAGE=${SLAVE_DIR}
81- else
82- SLAVE_BASE_IMAGE=${SLAVE_DIR}-march-${{ arch }}
83- fi
84-
85- tmpfile=$(mktemp)
86-
87- echo ${{ arch }} > .arch
88-
89- DOCKER_DATA_ROOT_FOR_MULTIARCH=/data/march/docker BLDENV=${{ dist }} $(BUILD_OPTIONS) make -f Makefile.work sonic-slave-build | tee $tmpfile
90- SLAVE_BASE_TAG=$(grep "^Checking sonic-slave-base image:" $tmpfile | awk -F ':' '{print $3}')
91- SLAVE_TAG=$(grep "^Checking sonic-slave image:" $tmpfile | awk -F ':' '{print $3}')
92-
93- mkdir -p target
94-
95- docker tag $SLAVE_BASE_IMAGE:$SLAVE_BASE_TAG $REGISTRY_SERVER/$SLAVE_BASE_IMAGE:latest
96- docker tag $SLAVE_BASE_IMAGE:$SLAVE_BASE_TAG $REGISTRY_SERVER/$SLAVE_BASE_IMAGE:$SLAVE_BASE_TAG
97- set +x
98- echo "##vso[task.setvariable variable=VARIABLE_SLAVE_BASE_IMAGE]$SLAVE_BASE_IMAGE"
99- echo "##vso[task.setvariable variable=VARIABLE_SLAVE_BASE_TAG]$SLAVE_BASE_TAG"
100- env:
101- REGISTRY_SERVER: ${{ parameters.registry_url }}
102- displayName: Build sonic-slave-${{ dist }}-${{ arch }}
103-
104- - task : Docker@2
105- displayName : Upload image
106- inputs :
107- containerRegistry : ${{ parameters.registry_conn }}
108- repository : $(VARIABLE_SLAVE_BASE_IMAGE)
109- command : push
110- tags : |
111- $(VARIABLE_SLAVE_BASE_TAG)
112- latest
64+ - template : .azure-pipelines/docker-sonic-slave-template.yml@buildimage
65+ parameters :
66+ pool : sonicbld
67+ arch : ${{ arch }}
68+ dist : ${{ dist }}
69+ - stage : Build_march
70+ dependsOn : []
71+ jobs :
72+ - ${{ each dist in parameters.dists }} :
73+ - ${{ if endswith(variables['Build.DefinitionName'], dist) }} :
74+ - ${{ each arch in parameters.arches }} :
75+ - ${{ if ne(arch, 'amd64') }} :
76+ - template : .azure-pipelines/docker-sonic-slave-template.yml@buildimage
77+ parameters :
78+ pool : sonicbld-${{ arch }}
79+ arch : ${{ arch }}
80+ dist : ${{ dist }}
81+ march : march_
0 commit comments