summaryrefslogtreecommitdiffstats
path: root/jjb/functest
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2015-11-11 00:57:52 +0100
committerFatih Degirmenci <fatih.degirmenci@ericsson.com>2015-11-17 15:57:13 +0000
commit57c83817b33ad9035be534f7c160259cbf11be60 (patch)
tree660f5129701ea47595b01b05d5e079ef5cba8c10 /jjb/functest
parent01b947838c11b191a133ed08f4abac5f906d26d4 (diff)
Add more if-else checks in functest docker build job
Also: update image with tag 'latest' JIRA: FUNCTEST-78 Change-Id: Idd1e143ada44ddb86d0bcb21c1b9ba4ed89675fc Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'jjb/functest')
-rw-r--r--jjb/functest/functest-docker.sh27
1 files changed, 20 insertions, 7 deletions
diff --git a/jjb/functest/functest-docker.sh b/jjb/functest/functest-docker.sh
index 883cb1b44..4de70d459 100644
--- a/jjb/functest/functest-docker.sh
+++ b/jjb/functest/functest-docker.sh
@@ -10,8 +10,12 @@ echo
DOCKER_IMAGE_NAME="opnfv/functest"
+
# Get tag version
-DOCKER_TAG=$(../../utils/calculate_version.sh -t docker -n $DOCKER_IMAGE_NAME)
+cd $WORKSPACE
+git clone https://gerrit.opnfv.org/gerrit/releng
+
+DOCKER_TAG=$($WORKSPACE/releng/utils/calculate_version.sh -t docker -n $DOCKER_IMAGE_NAME)
ret_val=$?
if [ $ret_val -ne 0 ]; then
@@ -23,18 +27,24 @@ fi
# Remove previous running containers
echo "Removing existing $DOCKER_IMAGE_NAME containers..."
-docker ps | grep $DOCKER_IMAGE_NAME | awk '{{print $1}}' | xargs docker stop &>/dev/null
-docker ps -a | grep $DOCKER_IMAGE_NAME | awk '{{print $1}}' | xargs docker rm &>/dev/null
+if [[ ! -z $(docker ps -a | grep $DOCKER_IMAGE_NAME) ]]; then
+ docker ps | grep $DOCKER_IMAGE_NAME | awk '{{print $1}}' | xargs docker stop &>/dev/null
+ docker ps -a | grep $DOCKER_IMAGE_NAME | awk '{{print $1}}' | xargs docker rm &>/dev/null
+fi
# Remove existing images
echo "Removing existing $DOCKER_IMAGE_NAME images..."
-docker images | grep $DOCKER_IMAGE_NAME | awk '{{print $3}}' | xargs docker rmi &>/dev/null
+if [[ ! -z $(docker images | grep $DOCKER_IMAGE_NAME) ]]; then
+ docker images | grep $DOCKER_IMAGE_NAME | awk '{{print $3}}' | xargs docker rmi &>/dev/null
+fi
# Start the build
-echo "Starting image build of $DOCKER_IMAGE_NAME:$DOCKER_TAG..."
-cd $WORKSPACE/docker/
+echo "Building of $DOCKER_IMAGE_NAME:$DOCKER_TAG..."
+cd $WORKSPACE/functest/docker
docker build -t $DOCKER_IMAGE_NAME:$DOCKER_TAG .
+echo "Creating tag 'latest'..."
+docker tag $DOCKER_IMAGE_NAME:$DOCKER_TAG $DOCKER_IMAGE_NAME:latest
# list the images
echo "Available images are:"
@@ -46,5 +56,8 @@ if [ "$PUSH_IMAGE" == "true" ]; then
echo "--------------------------------------------------------"
echo
# Push to the Dockerhub repository
- docker push $DOCKER_IMAGE_NAME:$DOCKER_TAG
+ docker push -f $DOCKER_IMAGE_NAME:$DOCKER_TAG
+
+ echo "Updating $DOCKER_IMAGE_NAME:latest to the docker registry..."
+ docker push -f $DOCKER_IMAGE_NAME:latest
fi