Time of day change
[releng.git] / jjb / releng / opnfv-docker.sh
index 9bd711b..2aa52ad 100644 (file)
@@ -17,14 +17,16 @@ echo "Starting opnfv-docker for $DOCKER_REPO_NAME ..."
 echo "--------------------------------------------------------"
 echo
 
-
-if [[ -n $(ps -ef|grep 'docker build'|grep -v grep) ]]; then
-    echo "There is already another build process in progress:"
-    echo $(ps -ef|grep 'docker build'|grep -v grep)
-    # Abort this job since it will collide and might mess up the current one.
-    echo "Aborting..."
-    exit 1
-fi
+count=30 # docker build jobs might take up to ~30 min
+while [[ -n `ps -ef|grep 'docker build'|grep -v grep` ]]; do
+    echo "Build in progress. Waiting..."
+    sleep 60
+    count=$(( $count - 1 ))
+    if [ $count -eq 0 ]; then
+        echo "Timeout. Aborting..."
+        exit 1
+    fi
+done
 
 # Remove previous running containers if exist
 if [[ -n "$(docker ps -a | grep $DOCKER_REPO_NAME)" ]]; then
@@ -73,14 +75,11 @@ echo "Current branch: $BRANCH"
 
 if [[ "$BRANCH" == "master" ]]; then
     DOCKER_TAG="latest"
+elif [[ -n "${RELEASE_VERSION-}" ]]; then
+    DOCKER_TAG=${BRANCH##*/}.${RELEASE_VERSION}
+    # e.g. danube.1.0, danube.2.0, danube.3.0
 else
-    if [[ -n "${RELEASE_VERSION-}" ]]; then
-        release=${BRANCH##*/}
-        DOCKER_TAG=${release}.${RELEASE_VERSION}
-        # e.g. colorado.1.0, colorado.2.0, colorado.3.0
-    else
-        DOCKER_TAG="stable"
-    fi
+    DOCKER_TAG="stable"
 fi
 
 # Start the build
@@ -88,6 +87,9 @@ echo "Building docker image: $DOCKER_REPO_NAME:$DOCKER_TAG"
 echo "--------------------------------------------------------"
 echo
 if [[ $DOCKER_REPO_NAME == *"dovetail"* ]]; then
+    if [[ -n "${RELEASE_VERSION-}" ]]; then
+        DOCKER_TAG=${RELEASE_VERSION}
+    fi
     cmd="docker build --no-cache -t $DOCKER_REPO_NAME:$DOCKER_TAG -f $DOCKERFILE ."
 else
     cmd="docker build --no-cache -t $DOCKER_REPO_NAME:$DOCKER_TAG --build-arg BRANCH=$BRANCH