Merge "KVMFORNFV: Enable artifact download and testing for daily job"
[releng.git] / jjb / qtip / qtip-cleanup.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2016 ZTE and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 echo "Cleaning up QTIP  docker containers/images..."
10
11 # Remove previous running containers if exist
12 if [[ ! -z $(docker ps -a | grep opnfv/qtip) ]]; then
13     echo "Removing existing opnfv/qtip containers..."
14     running_containers=$(docker ps | grep opnfv/qtip | awk '{print $1}')
15     docker stop ${running_containers}
16     all_containers=$(docker ps -a | grep opnfv/qtip | awk '{print $1}')
17     docker rm ${all_containers}
18 fi
19
20 # Remove existing images if exist
21 if [[ ! -z $(docker images | grep opnfv/qtip) ]]; then
22     echo "Docker images to remove:"
23     docker images | head -1 && docker images | grep opnfv/qtip
24     image_tags=($(docker images | grep opnfv/qtip | awk '{print $2}'))
25     for tag in "${image_tags[@]}"; do
26         echo "Removing docker image opnfv/qtip:$tag..."
27         docker rmi opnfv/qtip:$tag
28     done
29 fi
30