diff --git a/.azure-pipelines/azure-pipelines-UpgrateVersion.yml b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml index 03593c551c..6e11e3826e 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/docker-sonic-slave-template.yml b/.azure-pipelines/docker-sonic-slave-template.yml index a3d2d17dd0..24b16bd64b 100644 --- a/.azure-pipelines/docker-sonic-slave-template.yml +++ b/.azure-pipelines/docker-sonic-slave-template.yml @@ -45,7 +45,10 @@ jobs: pool: ${{ parameters.pool }} steps: - template: cleanup.yml - - template: .azure-pipelines/template-clean-sonic-slave.yml@buildimage + - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: + - template: template-clean-sonic-slave.yml + - ${{ else }}: + - template: .azure-pipelines/template-variables.yml@buildimage - checkout: self clean: true submodules: recursive diff --git a/.azure-pipelines/official-build.yml b/.azure-pipelines/official-build.yml index af43730915..8fe33e7706 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@buildimage + stages: - stage: Build pool: sonicbld diff --git a/.azure-pipelines/template-clean-sonic-slave.yml b/.azure-pipelines/template-clean-sonic-slave.yml new file mode 100644 index 0000000000..ddb8c8e48f --- /dev/null +++ b/.azure-pipelines/template-clean-sonic-slave.yml @@ -0,0 +1,10 @@ +steps: +- script: | + 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) + [ -n "$images" ] && docker rmi -f $images + exit 0 + displayName: 'Cleanup sonic slave' diff --git a/.azure-pipelines/template-variables.yml b/.azure-pipelines/template-variables.yml new file mode 100644 index 0000000000..f28768e39e --- /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 b3aa563307..1f0fd998d8 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['Build.Reason'], 'PullRequest') }}: + - template: .azure-pipelines/template-variables.yml +- ${{ else }}: + - template: .azure-pipelines/template-variables.yml@buildimage - name: CACHE_MODE value: rcache