[ci] Fix remove sonic-slave-* docker image issue when building sonic-slave* (#10296)
This commit is contained in:
parent
24397ead09
commit
90416b565c
@ -45,17 +45,7 @@ stages:
|
||||
jobFilters: ${{ parameters.jobFilters }}
|
||||
buildOptions: '${{ variables.VERSION_CONTROL_OPTIONS }} SONIC_BUILD_JOBS=$(nproc) ENABLE_IMAGE_SIGNATURE=y'
|
||||
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: template-clean-sonic-slave.yml
|
||||
- stage: UpgradeVersions
|
||||
jobs:
|
||||
- job: UpgradeVersions
|
||||
|
@ -38,6 +38,7 @@ jobs:
|
||||
pool: ${{ parameters.pool }}
|
||||
steps:
|
||||
- template: cleanup.yml
|
||||
- template: template-clean-sonic-slave.yml
|
||||
- checkout: self
|
||||
clean: true
|
||||
submodules: recursive
|
||||
@ -68,16 +69,6 @@ jobs:
|
||||
BUILD_OPTIONS = 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web,git,docker'
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
tmpfile=$(mktemp)
|
||||
|
||||
echo ${{ parameters.arch }} > .arch
|
||||
|
8
.azure-pipelines/template-clean-sonic-slave.yml
Normal file
8
.azure-pipelines/template-clean-sonic-slave.yml
Normal file
@ -0,0 +1,8 @@
|
||||
steps:
|
||||
- script: |
|
||||
containers=$(docker container ls -a | grep "sonic-slave" | awk '{ print $1 }')
|
||||
[ -n "$containers" ] && docker container rm -f containers
|
||||
docker images | grep "^<none>" | awk '{print$3}' | xargs -i docker rmi {}
|
||||
images=$(docker images 'sonic-slave-*' -a -q)
|
||||
[ -n "$images" ] && docker rmi -f $images
|
||||
displayName: 'Cleanup sonic slave'
|
Loading…
Reference in New Issue
Block a user