From 449ae1332f0da770633ec28eae0d7c8e1675411d Mon Sep 17 00:00:00 2001 From: Liu Shilong Date: Mon, 26 Dec 2022 10:35:15 +0800 Subject: [PATCH] [ci] Add branch tag on sonic-slave-bullseye image. (#13151) Why I did it tag sonic-slave-* image with branch. Only keep sonic-slave-* latest tag when it is master branch and amd64 arch. How I did it How to verify it --- .azure-pipelines/docker-sonic-slave-template.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.azure-pipelines/docker-sonic-slave-template.yml b/.azure-pipelines/docker-sonic-slave-template.yml index 142ff5fa3f..abc955457f 100644 --- a/.azure-pipelines/docker-sonic-slave-template.yml +++ b/.azure-pipelines/docker-sonic-slave-template.yml @@ -56,6 +56,7 @@ 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) + image_branch=$(echo $(echo $image_tag | 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 +70,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 [[ "${{ parameters.arch }}" == "amd64" ]] && [[ "$(Build.SourceBranchName)" == "master" ]];then docker tag ${image_tag} ${REGISTRY_SERVER}/${image_latest} docker push ${REGISTRY_SERVER}/${image_latest} fi