[ci] Fix remove sonic-slave-* docker image issue when building sonic-slave* (#10296) (#10378)

This commit is contained in:
Shilong Liu 2022-03-30 16:08:32 +08:00 committed by GitHub
parent e9db38594d
commit 491562b74b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,14 @@ schedules:
- 202012
always: true
resources:
repositories:
- repository: buildimage
type: github
name: Azure/sonic-buildimage
ref: master
endpoint: build
pool: sonicbld
parameters:
@ -42,17 +50,7 @@ stages:
buildOptions: '${{ variables.VERSION_CONTROL_OPTIONS }} SONIC_BUILD_JOBS=$(nproc) ENABLE_IMAGE_SIGNATURE=y'
jobFilters: ${{ parameters.jobFilters }}
preSteps:
- script: |
containers=$(docker container ls | grep "sonic-slave" | awk '{ print $1 }')
if [ ! -z "$containers" ]; then
docker container kill $containers || true
sleep 5
fi
images=$(docker images 'sonic-slave-*' -a -q)
if [ ! -z "$images" ]; then
docker rmi -f $images
fi
displayName: 'Cleanup sonic slave'
- template: .azure-pipelines/template-clean-sonic-slave.yml@buildimage
- stage: UpgradeVersions
jobs:
- job: UpgradeVersions