X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Ffunctest%2Ffunctest-cleanup.sh;h=c21b543a62789e28542f0b424e58b253dd63efde;hb=afff1f88a918215eeb9060c4f43c5a332c8eb32c;hp=b03d4778d02b8e7a9f8c47f4b3f12cb738511f9b;hpb=0a67d3606166bcb3ccb04dae3bddf24d3ce8efd2;p=releng.git diff --git a/jjb/functest/functest-cleanup.sh b/jjb/functest/functest-cleanup.sh index b03d4778d..c21b543a6 100755 --- a/jjb/functest/functest-cleanup.sh +++ b/jjb/functest/functest-cleanup.sh @@ -4,13 +4,17 @@ echo "Cleaning up docker containers/images..." FUNCTEST_IMAGE=opnfv/functest -# Remove containers along with image opnfv/functest: + +# Remove containers along with image opnfv/functest*: dangling_images=($(docker images -f "dangling=true" | grep $FUNCTEST_IMAGE | awk '{print $3}')) if [[ -n ${dangling_images} ]]; then echo " Removing $FUNCTEST_IMAGE: images and their containers..." for image_id in "${dangling_images[@]}"; do echo " Removing image_id: $image_id and its containers" - docker ps -a | grep $image_id | awk '{print $1}'| xargs docker rm -f >${redirect} + containers=$(docker ps -a | grep $image_id | awk '{print $1}') + if [[ -n "$containers" ]];then + docker rm -f $containers >${redirect} + fi docker rmi $image_id >${redirect} done fi