summaryrefslogtreecommitdiffstats
path: root/jjb
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2015-11-18 16:05:29 +0100
committerFatih Degirmenci <fatih.degirmenci@ericsson.com>2015-11-19 13:07:15 +0000
commit18bd98e4bf60111367323e522aadb0ecc644a2e7 (patch)
treea58c20b5e98b7b68628ef812b415b294d4e81a6d /jjb
parentbd1799ce5a7786d7fcf7b2f82e729d66627c2f9f (diff)
Delete docker images by tag in Functest docker job
JIRA: FUNCTEST-78 Change-Id: Ibb0be531149fed848caa1670dcc1d53c607d26d2 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'jjb')
-rw-r--r--jjb/functest/functest-docker.sh16
1 files changed, 9 insertions, 7 deletions
diff --git a/jjb/functest/functest-docker.sh b/jjb/functest/functest-docker.sh
index 54315cad1..c73bcf99a 100644
--- a/jjb/functest/functest-docker.sh
+++ b/jjb/functest/functest-docker.sh
@@ -26,6 +26,7 @@ else
echo "Tag version to be build and pushed: $DOCKER_TAG"
fi
+
# Remove previous running containers if exist
if [[ ! -z $(docker ps -a | grep $DOCKER_IMAGE_NAME) ]]; then
echo "Removing existing $DOCKER_IMAGE_NAME containers..."
@@ -33,20 +34,21 @@ if [[ ! -z $(docker ps -a | grep $DOCKER_IMAGE_NAME) ]]; then
docker ps -a | grep $DOCKER_IMAGE_NAME | awk '{{print $1}}' | xargs docker rm
fi
-# list the images
-echo "Available images are:"
-docker images
# Remove existing images if exist
if [[ ! -z $(docker images | grep $DOCKER_IMAGE_NAME) ]]; then
- echo "Removing existing $DOCKER_IMAGE_NAME images..."
- docker images | grep $DOCKER_IMAGE_NAME | awk '{{print $3}}' \
- | xargs docker rmi -f
+ echo "Docker images to remove:"
+ docker images | head -1 && docker images | grep $DOCKER_IMAGE_NAME
+ image_tags=($(docker images | grep $DOCKER_IMAGE_NAME | awk '{{print $2}}'))
+ for tag in "${{image_tags[@]}}"; do
+ echo "Removing docker image $DOCKER_IMAGE_NAME:$tag..."
+ docker rmi $DOCKER_IMAGE_NAME:$tag
+ done
fi
# Start the build
-echo "Building of $DOCKER_IMAGE_NAME:$DOCKER_TAG..."
+echo "Building docker image: $DOCKER_IMAGE_NAME:$DOCKER_TAG..."
cd $WORKSPACE/docker
docker build -t $DOCKER_IMAGE_NAME:$DOCKER_TAG .
echo "Creating tag 'latest'..."