X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Freleng%2Fopnfv-docker.sh;h=c179b1d8e7cc296740c44ad3bd2e0b886e911b45;hb=e25af7fd788db267247abb6b4efa4cf2dff73f32;hp=954d7c8abab09f9509a38a54e0629ada2f43c172;hpb=4ba227e8fcd2a5e20bb04ecf9cbc7779f8039f32;p=releng.git diff --git a/jjb/releng/opnfv-docker.sh b/jjb/releng/opnfv-docker.sh index 954d7c8ab..c179b1d8e 100644 --- a/jjb/releng/opnfv-docker.sh +++ b/jjb/releng/opnfv-docker.sh @@ -17,6 +17,17 @@ echo "Starting opnfv-docker for $DOCKER_REPO_NAME ..." echo "--------------------------------------------------------" echo +count=30 # docker build jobs might take up to ~30 min +while [[ -n `ps -ef| grep 'docker build' | grep $DOCKER_REPO_NAME | grep -v grep` ]]; do + echo "Build or cleanup of $DOCKER_REPO_NAME 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 echo "Removing existing $DOCKER_REPO_NAME containers..." @@ -43,20 +54,13 @@ if [[ -n "$(docker images | grep $DOCKER_REPO_NAME)" ]]; then done fi -cd $WORKSPACE/$DOCKER_DIR -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 +cd "$WORKSPACE/$DOCKER_DIR" || exit 1 +HOST_ARCH="$(uname -m)" +#If there is a patch for other arch then x86, apply the patch and +#replace Dockerfile file +dockerfile_patch="Dockerfile.${HOST_ARCH}.patch" +if [[ -f "${dockerfile_patch}" ]]; then + patch -f Dockerfile -p1 < "${dockerfile_patch}" fi # Get tag version @@ -67,8 +71,14 @@ BUILD_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 + DOCKER_TAG=${RELEASE_VERSION} + if git checkout ${RELEASE_VERSION}; then + echo "Successfully checked out the git tag ${RELEASE_VERSION}" + else + echo "The tag ${RELEASE_VERSION} doesn't exist in the repository. Existing tags are:" + git tag + exit 1 + fi else DOCKER_TAG="stable" fi @@ -90,7 +100,6 @@ echo "Building docker image: $DOCKER_REPO_NAME:$DOCKER_TAG" echo "--------------------------------------------------------" echo cmd="docker build --no-cache -t $DOCKER_REPO_NAME:$DOCKER_TAG --build-arg BRANCH=$BUILD_BRANCH - $ARCH_BUILD_ARG -f $DOCKERFILE ." echo ${cmd}