Clean Functest images for CI jobs on ARM
[releng.git] / jjb / functest / functest-cleanup.sh
index b03d477..c21b543 100755 (executable)
@@ -4,13 +4,17 @@
 
 echo "Cleaning up docker containers/images..."
 FUNCTEST_IMAGE=opnfv/functest
-# Remove containers along with image opnfv/functest:<none>
+
+# Remove containers along with image opnfv/functest*:<none>
 dangling_images=($(docker images -f "dangling=true" | grep $FUNCTEST_IMAGE | awk '{print $3}'))
 if [[ -n ${dangling_images} ]]; then
     echo "  Removing $FUNCTEST_IMAGE:<none> 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