summaryrefslogtreecommitdiffstats
path: root/jjb
diff options
context:
space:
mode:
Diffstat (limited to 'jjb')
-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