60365bfcb7
Why I did it Currently sonic-slave-* tag is confusing. Set correct tag on sonic-slave-* image. Fix job name to fit the build. How I did it build amd image in amd64: sonic-slave-bullseye:cfe29bff67c sonic-slave-bullseye:latest sonic-slave-bullseye:master build armhf image in amd64: sonic-slave-bullseye-march-armhf:33614806dc3 sonic-slave-bullseye-march-armhf:latest sonic-slave-bullseye-march-armhf:master build arm64 image in amd64: sonic-slave-bullseye-march-arm64:f3b1b16c801 sonic-slave-bullseye-march-arm64:latest sonic-slave-bullseye-march-arm64:master build arm64 image in arm64: sonic-slave-bullseye:75cb326c9a7 sonic-slave-bullseye-arm64:latest sonic-slave-bullseye:master build armhf image in armhf: sonic-slave-bullseye:64d178951fc sonic-slave-bullseye-armhf:latest sonic-slave-bullseye:master How to verify it
84 lines
2.8 KiB
YAML
84 lines
2.8 KiB
YAML
# Starter pipeline
|
|
# Start with a minimal pipeline that you can customize to build and deploy your code.
|
|
# Add steps that build, run tests, deploy, and more:
|
|
# https://aka.ms/yaml
|
|
# Build and push sonic-slave-[buster|jessie|stretch] images for amd64/armhf/arm64
|
|
parameters:
|
|
- name: arch
|
|
type: string
|
|
values:
|
|
- amd64
|
|
- armhf
|
|
- arm64
|
|
- name: march
|
|
type: string
|
|
default: ''
|
|
- name: dist
|
|
type: string
|
|
values:
|
|
- bullseye
|
|
- buster
|
|
- stretch
|
|
- jessie
|
|
- name: registry_url
|
|
type: string
|
|
default: sonicdev-microsoft.azurecr.io
|
|
- name: registry_conn
|
|
type: string
|
|
default: sonicdev
|
|
- name: pool
|
|
type: string
|
|
default: sonicbld
|
|
values:
|
|
- sonicbld
|
|
- sonicbld-arm64
|
|
- sonicbld-armhf
|
|
|
|
jobs:
|
|
- job: sonic_slave_${{ parameters.dist }}${{ parameters.march }}
|
|
timeoutInMinutes: 360
|
|
variables:
|
|
- template: /.azure-pipelines/template-variables.yml@buildimage
|
|
- template: /.azure-pipelines/azure-pipelines-repd-build-variables.yml@buildimage
|
|
pool: ${{ parameters.pool }}
|
|
steps:
|
|
- template: cleanup.yml
|
|
- template: /.azure-pipelines/template-clean-sonic-slave.yml@buildimage
|
|
- checkout: self
|
|
clean: true
|
|
- task: Docker@2
|
|
displayName: Login to ACR
|
|
inputs:
|
|
command: login
|
|
containerRegistry: ${{ parameters.registry_conn }}
|
|
- bash: |
|
|
set -ex
|
|
image_tag=$(BLDENV=${{ parameters.dist }} make -f Makefile.work showtag PLATFORM=generic PLATFORM_ARCH=${{ parameters.arch }} | grep sonic-slave | tail -n 1)
|
|
image_latest=$(echo $(echo $image_tag | awk -F: '{print$1}'):latest)
|
|
if echo ${{ parameters.pool }} | grep ${{ parameters.arch }};then
|
|
image_latest=$(echo ${image_latest} | sed 's/:/-${{ parameters.arch }}:/')
|
|
fi
|
|
image_branch=$(echo $(echo $image_latest | awk -F: '{print$1}'):$(Build.SourceBranchName))
|
|
docker rmi $image_tag || true
|
|
|
|
if [[ "$(Build.Reason)" =~ [a-zA-Z]*CI ]] && docker pull ${{ parameters.registry_url }}/${image_tag};then
|
|
exit 0
|
|
fi
|
|
|
|
DOCKER_DATA_ROOT_FOR_MULTIARCH=/data/march/docker BLDENV=${{ parameters.dist }} make -f Makefile.work configure PLATFORM=generic PLATFORM_ARCH=${{ parameters.arch }} $args || docker image ls $image_tag
|
|
if [[ "$(Build.Reason)" == "PullRequest" ]];then
|
|
exit 0
|
|
fi
|
|
|
|
docker tag ${image_tag} ${REGISTRY_SERVER}/${image_tag}
|
|
docker push ${REGISTRY_SERVER}/${image_tag}
|
|
docker tag ${image_tag} ${REGISTRY_SERVER}/${image_branch}
|
|
docker push ${REGISTRY_SERVER}/${image_branch}
|
|
if [[ "$(Build.SourceBranchName)" == "master" ]];then
|
|
docker tag ${image_tag} ${REGISTRY_SERVER}/${image_latest}
|
|
docker push ${REGISTRY_SERVER}/${image_latest}
|
|
fi
|
|
env:
|
|
REGISTRY_SERVER: ${{ parameters.registry_url }}
|
|
displayName: Build sonic-slave-${{ parameters.dist }}-${{ parameters.arch }}
|