X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Freleng%2Fopnfv-docker.sh;h=2aa52adc5c191eab5617b5104986564d84ae1fad;hb=6b50609d6ffb5e6ab81b0ad5d8c33e1a49bfd6c2;hp=ded743d7e5cc798947a09dec0a9bff33a09b58ee;hpb=2a1abd9aa9a2371cfa86d3e64ac1c81e3a835c31;p=releng.git diff --git a/jjb/releng/opnfv-docker.sh b/jjb/releng/opnfv-docker.sh index ded743d7e..2aa52adc5 100644 --- a/jjb/releng/opnfv-docker.sh +++ b/jjb/releng/opnfv-docker.sh @@ -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 @@ -53,9 +55,19 @@ if [[ -n "$(docker images | grep $DOCKER_REPO_NAME)" ]]; then fi cd $WORKSPACE/docker -if [ ! -f ${DOCKERFILE} ]; then - echo "ERROR: Dockerfile not found." - exit 1 +HOST_ARCH=$(uname -m) +if [ ! -f "${DOCKERFILE}" ]; then + # If this is expected to be a Dockerfile for other arch than x86 + # and it does not exist, but there is a patch for the said arch, + # then apply the patch and create the Dockerfile.${HOST_ARCH} file + if [[ "${DOCKERFILE}" == *"${HOST_ARCH}" && \ + -f "Dockerfile.${HOST_ARCH}.patch" ]]; then + patch -o Dockerfile."${HOST_ARCH}" Dockerfile \ + Dockerfile."${HOST_ARCH}".patch + else + echo "ERROR: No Dockerfile or ${HOST_ARCH} patch found." + exit 1 + fi fi # Get tag version @@ -63,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 [[ "$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 @@ -78,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