Merge "KVMFORNFV: Implementing kvmfornfv daily jobs."
[releng.git] / jjb / dovetail / dovetail-cleanup.sh
1 #!/bin/bash
2
3 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
4
5 echo "Cleaning up docker containers/images..."
6 # Remove previous running containers if exist
7 if [[ ! -z $(docker ps -a | grep opnfv/dovetail) ]]; then
8     echo "Removing existing opnfv/dovetail containers..."
9     docker ps -a | grep opnfv/dovetail | awk '{print $1}' | xargs docker rm -f >${redirect}
10 fi
11
12 # Remove existing images if exist
13 if [[ ! -z $(docker images | grep opnfv/dovetail) ]]; then
14     echo "Docker images to remove:"
15     docker images | head -1 && docker images | grep opnfv/dovetail >${redirect}
16     image_tags=($(docker images | grep opnfv/dovetail | awk '{print $2}'))
17     for tag in "${image_tags[@]}"; do
18         echo "Removing docker image opnfv/dovetail:$tag..."
19         docker rmi opnfv/dovetail:$tag >${redirect}
20     done
21 fi