From b7956b50a3fe059ca6b41f270a7c0206082ac76f Mon Sep 17 00:00:00 2001 From: shilongliu Date: Fri, 1 Apr 2022 16:54:28 +0800 Subject: [PATCH 1/9] [ci] Use ACR instead of docker hub. fix a bug in clean docker image --- .azure-pipelines/azure-pipelines-UpgrateVersion.yml | 7 +++++-- .azure-pipelines/official-build.yml | 11 +++++++++++ .azure-pipelines/template-clean-sonic-slave.yml | 3 ++- .azure-pipelines/template-variables.yml | 2 ++ azure-pipelines.yml | 9 +++++++++ 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 .azure-pipelines/template-variables.yml diff --git a/.azure-pipelines/azure-pipelines-UpgrateVersion.yml b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml index 03593c551cf..6e11e3826e5 100644 --- a/.azure-pipelines/azure-pipelines-UpgrateVersion.yml +++ b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml @@ -45,8 +45,11 @@ parameters: stages: - stage: Build variables: - CACHE_MODE: none - VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=' + - name: CACHE_MODE + value: none + - name: VERSION_CONTROL_OPTIONS + value: 'SONIC_VERSION_CONTROL_COMPONENTS=' + - template: .azure-pipelines/template-variables.yml@buildimage jobs: - template: azure-pipelines-build.yml parameters: diff --git a/.azure-pipelines/official-build.yml b/.azure-pipelines/official-build.yml index f43c6521fc5..165ae8eca42 100644 --- a/.azure-pipelines/official-build.yml +++ b/.azure-pipelines/official-build.yml @@ -18,9 +18,20 @@ schedules: - 201911 - 201811 +resources: + repositories: + - repository: buildimage + type: github + name: Azure/sonic-buildimage + ref: master + endpoint: build + trigger: none pr: none +variables: +- template: .azure-pipelines/template-variables.yml + stages: - stage: Build pool: sonicbld diff --git a/.azure-pipelines/template-clean-sonic-slave.yml b/.azure-pipelines/template-clean-sonic-slave.yml index c67f63fff47..b99a80b82e8 100644 --- a/.azure-pipelines/template-clean-sonic-slave.yml +++ b/.azure-pipelines/template-clean-sonic-slave.yml @@ -1,6 +1,7 @@ steps: - script: | - containers=$(docker container ls -a | grep "sonic-slave" | awk '{ print $1 }') + set -x + containers=$(docker container ls -aq) [ -n "$containers" ] && docker container rm -f $containers docker images | grep "^" | awk '{print$3}' | xargs -i docker rmi {} images=$(docker images 'sonic-slave-*' -a -q) diff --git a/.azure-pipelines/template-variables.yml b/.azure-pipelines/template-variables.yml new file mode 100644 index 00000000000..f28768e39ef --- /dev/null +++ b/.azure-pipelines/template-variables.yml @@ -0,0 +1,2 @@ +variables: + DEFAULT_CONTAINER_REGISTRY: 'publicmirror.azurecr.io' diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 557ce3beff8..fb040f3ee6d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,9 +30,18 @@ resources: type: github name: Azure/sonic-mgmt endpoint: build + - repository: buildimage + type: github + name: Azure/sonic-buildimage + endpoint: build + ref: master variables: - template: .azure-pipelines/azure-pipelines-repd-build-variables.yml +- ${{ if eq(variables['System.PullRequest.TargetBranch'], 'master') }}: + - template: .azure-pipelines/template-variables.yml +- ${{ else }}: + - template: .azure-pipelines/template-variables.yml@buildimage - name: CACHE_MODE value: rcache From 4e67d092fcbcd9906028bec0a489cc1dc46aeb0f Mon Sep 17 00:00:00 2001 From: shilongliu Date: Fri, 1 Apr 2022 16:55:46 +0800 Subject: [PATCH 2/9] fix --- .azure-pipelines/official-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/official-build.yml b/.azure-pipelines/official-build.yml index 165ae8eca42..fb986cf6703 100644 --- a/.azure-pipelines/official-build.yml +++ b/.azure-pipelines/official-build.yml @@ -30,7 +30,7 @@ trigger: none pr: none variables: -- template: .azure-pipelines/template-variables.yml +- template: .azure-pipelines/template-variables.yml@buildimage stages: - stage: Build From f88c8fe8457fed8d2bd2d67810021dbd6df6df08 Mon Sep 17 00:00:00 2001 From: shilongliu Date: Fri, 1 Apr 2022 17:04:01 +0800 Subject: [PATCH 3/9] fix --- .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 6b4b90f371d..8fa233372e6 100644 --- a/.azure-pipelines/docker-sonic-slave-template.yml +++ b/.azure-pipelines/docker-sonic-slave-template.yml @@ -37,7 +37,10 @@ jobs: pool: ${{ parameters.pool }} steps: - template: cleanup.yml - - template: .azure-pipelines/template-clean-sonic-slave.yml@buildimage + - ${{ if eq(variables['System.PullRequest.TargetBranch'], 'master') }}: + - template: template-clean-sonic-slave.yml + - ${{ else }}: + - template: .azure-pipelines/template-variables.yml@buildimage - checkout: self clean: true submodules: recursive From 83664edb658f7f5c29f48ea2f22ebd6220ebeff8 Mon Sep 17 00:00:00 2001 From: shilongliu Date: Fri, 1 Apr 2022 17:24:53 +0800 Subject: [PATCH 4/9] fix --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fb040f3ee6d..983a34a4191 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,7 +38,7 @@ resources: variables: - template: .azure-pipelines/azure-pipelines-repd-build-variables.yml -- ${{ if eq(variables['System.PullRequest.TargetBranch'], 'master') }}: +- ${{ if eq(variables['System.PullRequest.SourceBranch'], 'master') }}: - template: .azure-pipelines/template-variables.yml - ${{ else }}: - template: .azure-pipelines/template-variables.yml@buildimage From 86bca056273d36d36b7fcf17ecca6bcc157403e6 Mon Sep 17 00:00:00 2001 From: shilongliu Date: Fri, 1 Apr 2022 17:30:54 +0800 Subject: [PATCH 5/9] fix --- azure-pipelines.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 983a34a4191..7325c168f56 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,16 +38,17 @@ resources: variables: - template: .azure-pipelines/azure-pipelines-repd-build-variables.yml -- ${{ if eq(variables['System.PullRequest.SourceBranch'], 'master') }}: - - template: .azure-pipelines/template-variables.yml -- ${{ else }}: - - template: .azure-pipelines/template-variables.yml@buildimage - name: CACHE_MODE value: rcache stages: - stage: BuildVS pool: sonicbld + variables: + - ${{ if eq(variables['System.PullRequest.SourceBranch'], 'master') }}: + - template: .azure-pipelines/template-variables.yml + - ${{ else }}: + - template: .azure-pipelines/template-variables.yml@buildimage jobs: - template: .azure-pipelines/azure-pipelines-build.yml parameters: From 43c721241622e5bf53a5bf7e65416cbe7b83c4d5 Mon Sep 17 00:00:00 2001 From: shilongliu Date: Fri, 1 Apr 2022 17:33:30 +0800 Subject: [PATCH 6/9] Revert "fix" This reverts commit 86bca056273d36d36b7fcf17ecca6bcc157403e6. --- azure-pipelines.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7325c168f56..983a34a4191 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,17 +38,16 @@ resources: variables: - template: .azure-pipelines/azure-pipelines-repd-build-variables.yml +- ${{ if eq(variables['System.PullRequest.SourceBranch'], 'master') }}: + - template: .azure-pipelines/template-variables.yml +- ${{ else }}: + - template: .azure-pipelines/template-variables.yml@buildimage - name: CACHE_MODE value: rcache stages: - stage: BuildVS pool: sonicbld - variables: - - ${{ if eq(variables['System.PullRequest.SourceBranch'], 'master') }}: - - template: .azure-pipelines/template-variables.yml - - ${{ else }}: - - template: .azure-pipelines/template-variables.yml@buildimage jobs: - template: .azure-pipelines/azure-pipelines-build.yml parameters: From 506ad670df18ed934f6d019222c88a5c213a0e2d Mon Sep 17 00:00:00 2001 From: shilongliu Date: Fri, 1 Apr 2022 17:38:22 +0800 Subject: [PATCH 7/9] fix --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 983a34a4191..27836a49b1a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,7 +38,7 @@ resources: variables: - template: .azure-pipelines/azure-pipelines-repd-build-variables.yml -- ${{ if eq(variables['System.PullRequest.SourceBranch'], 'master') }}: +- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - template: .azure-pipelines/template-variables.yml - ${{ else }}: - template: .azure-pipelines/template-variables.yml@buildimage From 8e240d5415db3b5b1e8e03cbf4e6edb8c49dd15d Mon Sep 17 00:00:00 2001 From: shilongliu Date: Fri, 1 Apr 2022 17:40:16 +0800 Subject: [PATCH 8/9] fix --- .azure-pipelines/docker-sonic-slave-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/docker-sonic-slave-template.yml b/.azure-pipelines/docker-sonic-slave-template.yml index 8fa233372e6..2a9421dda33 100644 --- a/.azure-pipelines/docker-sonic-slave-template.yml +++ b/.azure-pipelines/docker-sonic-slave-template.yml @@ -37,7 +37,7 @@ jobs: pool: ${{ parameters.pool }} steps: - template: cleanup.yml - - ${{ if eq(variables['System.PullRequest.TargetBranch'], 'master') }}: + - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - template: template-clean-sonic-slave.yml - ${{ else }}: - template: .azure-pipelines/template-variables.yml@buildimage From 90aeb4aa96f2411cc9194ee32a1846ce7f92062f Mon Sep 17 00:00:00 2001 From: shilongliu Date: Fri, 1 Apr 2022 17:47:43 +0800 Subject: [PATCH 9/9] fix --- .azure-pipelines/template-clean-sonic-slave.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.azure-pipelines/template-clean-sonic-slave.yml b/.azure-pipelines/template-clean-sonic-slave.yml index b99a80b82e8..ddb8c8e48f6 100644 --- a/.azure-pipelines/template-clean-sonic-slave.yml +++ b/.azure-pipelines/template-clean-sonic-slave.yml @@ -6,4 +6,5 @@ steps: docker images | grep "^" | awk '{print$3}' | xargs -i docker rmi {} images=$(docker images 'sonic-slave-*' -a -q) [ -n "$images" ] && docker rmi -f $images + exit 0 displayName: 'Cleanup sonic slave'