summaryrefslogtreecommitdiffstats
path: root/jjb
diff options
context:
space:
mode:
authorMatthewLi <matthew.lijun@huawei.com>2016-12-26 01:47:17 -0500
committerMatthewLi <matthew.lijun@huawei.com>2016-12-28 03:14:52 -0500
commitf7613900fb522fc8e8f811cfa192de457e3c9524 (patch)
treeab1b04d2fbda0c3ab8f53e7bc0f52bf372d2491e /jjb
parent53ed9e36a13d03455fc04b3f54ed290037359f6b (diff)
dovetail: rewrite cleanup images process
Change-Id: Id4f9f1ddb7d84e5780479a7ca2bc979132dde8d4 Signed-off-by: MatthewLi <matthew.lijun@huawei.com>
Diffstat (limited to 'jjb')
-rwxr-xr-xjjb/dovetail/dovetail-cleanup.sh27
1 files changed, 24 insertions, 3 deletions
diff --git a/jjb/dovetail/dovetail-cleanup.sh b/jjb/dovetail/dovetail-cleanup.sh
index f215278db..22b2ba2ce 100755
--- a/jjb/dovetail/dovetail-cleanup.sh
+++ b/jjb/dovetail/dovetail-cleanup.sh
@@ -2,14 +2,35 @@
[[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
-echo "Cleaning up docker containers/images..."
-# Remove previous running containers if exist
+#clean up dependent project docker images, which has no containers and image tag None
+clean_images=(opnfv/functest opnfv/yardstick)
+for clean_image in "${clean_images[@]}"; do
+ echo "Removing image $image_id, which has no containers and image tag is None"
+ dangling_images=($(docker images -f "dangling=true" | grep ${clean_image} | awk '{print $3}'))
+ if [[ -n ${dangling_images} ]]; then
+ for image_id in "${dangling_images[@]}"; do
+ docker rmi $image_id >${redirect}
+ done
+ fi
+done
+
+echo "Remove containers with image dovetail:<None>..."
+dangling_images=($(docker images -f "dangling=true" | grep opnfv/dovetail | awk '{print $3}'))
+if [[ -n ${dangling_images} ]]; then
+ for image_id in "${dangling_images[@]}"; do
+ echo "Removing image $image_id with tag None and its related containers"
+ docker ps -a | grep $image_id | awk '{print $1}'| xargs docker rm -f >${redirect}
+ docker rmi $image_id >${redirect}
+ done
+fi
+
+echo "Cleaning up dovetail docker containers/images..."
if [[ ! -z $(docker ps -a | grep opnfv/dovetail) ]]; then
echo "Removing existing opnfv/dovetail containers..."
docker ps -a | grep opnfv/dovetail | awk '{print $1}' | xargs docker rm -f >${redirect}
fi
-# Remove existing images if exist
+echo "Remove dovetail existing images if exist..."
if [[ ! -z $(docker images | grep opnfv/dovetail) ]]; then
echo "Docker images to remove:"
docker images | head -1 && docker images | grep opnfv/dovetail >${redirect}