From 60365bfcb77c5cac6e013874124559573fcef466 Mon Sep 17 00:00:00 2001 From: Liu Shilong Date: Wed, 28 Dec 2022 16:33:47 +0800 Subject: [PATCH] Fix sonic slave pipeline to set correct tag on sonic slave image. (#13177) (#13186) 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 --- .azure-pipelines/docker-sonic-slave-template.yml | 11 ++++++++--- .azure-pipelines/docker-sonic-slave.yml | 9 +++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.azure-pipelines/docker-sonic-slave-template.yml b/.azure-pipelines/docker-sonic-slave-template.yml index 142ff5fa3f6f..828f958e5ed2 100644 --- a/.azure-pipelines/docker-sonic-slave-template.yml +++ b/.azure-pipelines/docker-sonic-slave-template.yml @@ -35,7 +35,7 @@ parameters: - sonicbld-armhf jobs: -- job: Build_${{ parameters.dist }}_${{ parameters.march }}${{ parameters.arch }} +- job: sonic_slave_${{ parameters.dist }}${{ parameters.march }} timeoutInMinutes: 360 variables: - template: /.azure-pipelines/template-variables.yml@buildimage @@ -46,7 +46,6 @@ jobs: - template: /.azure-pipelines/template-clean-sonic-slave.yml@buildimage - checkout: self clean: true - submodules: recursive - task: Docker@2 displayName: Login to ACR inputs: @@ -56,6 +55,10 @@ jobs: 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 @@ -69,7 +72,9 @@ jobs: docker tag ${image_tag} ${REGISTRY_SERVER}/${image_tag} docker push ${REGISTRY_SERVER}/${image_tag} - if [[ "${{ parameters.arch }}" == "amd64" ]];then + 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 diff --git a/.azure-pipelines/docker-sonic-slave.yml b/.azure-pipelines/docker-sonic-slave.yml index dd7a11d2c531..4c679f7f9518 100644 --- a/.azure-pipelines/docker-sonic-slave.yml +++ b/.azure-pipelines/docker-sonic-slave.yml @@ -30,7 +30,6 @@ trigger: paths: include: - sonic-slave-* - - src/sonic-build-hooks - files/build/versions - Makefile - Makefile.work @@ -57,7 +56,7 @@ parameters: default: sonicdev stages: -- stage: Build +- stage: Build_in_amd64 jobs: - ${{ each dist in parameters.dists }}: - ${{ if endswith(variables['Build.DefinitionName'], dist) }}: @@ -67,7 +66,9 @@ stages: pool: sonicbld arch: ${{ arch }} dist: ${{ dist }} -- stage: Build_march + ${{ if ne(arch, 'amd64') }}: + march: _march_${{ arch }} +- stage: Build_native_arm dependsOn: [] jobs: - ${{ each dist in parameters.dists }}: @@ -79,4 +80,4 @@ stages: pool: sonicbld-${{ arch }} arch: ${{ arch }} dist: ${{ dist }} - march: march_ + march: _${{ arch }}