diff options
Diffstat (limited to 'jjb/functest')
-rw-r--r-- | jjb/functest/functest-docker.sh | 26 | ||||
-rw-r--r-- | jjb/functest/functest.yml | 12 |
2 files changed, 22 insertions, 16 deletions
diff --git a/jjb/functest/functest-docker.sh b/jjb/functest/functest-docker.sh index 6f752c221..c73bcf99a 100644 --- a/jjb/functest/functest-docker.sh +++ b/jjb/functest/functest-docker.sh @@ -15,7 +15,8 @@ DOCKER_IMAGE_NAME="opnfv/functest" cd $WORKSPACE git clone https://gerrit.opnfv.org/gerrit/releng -DOCKER_TAG=$($WORKSPACE/releng/utils/calculate_version.sh -t docker -n $DOCKER_IMAGE_NAME) +DOCKER_TAG=$($WORKSPACE/releng/utils/calculate_version.sh -t docker \ + -n $DOCKER_IMAGE_NAME) ret_val=$? if [ $ret_val -ne 0 ]; then @@ -25,22 +26,29 @@ else echo "Tag version to be build and pushed: $DOCKER_TAG" fi -# Remove previous running containers -echo "Removing existing $DOCKER_IMAGE_NAME containers..." + +# Remove previous running containers if exist 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 + echo "Removing existing $DOCKER_IMAGE_NAME containers..." + docker ps | grep $DOCKER_IMAGE_NAME | awk '{{print $1}}' | xargs docker stop + docker ps -a | grep $DOCKER_IMAGE_NAME | awk '{{print $1}}' | xargs docker rm fi -# Remove existing images -echo "Removing existing $DOCKER_IMAGE_NAME images..." + +# Remove existing images if exist if [[ ! -z $(docker images | grep $DOCKER_IMAGE_NAME) ]]; then - docker images | grep $DOCKER_IMAGE_NAME | awk '{{print $3}}' | xargs docker rmi &>/dev/null + echo "Docker images to remove:" + docker images | head -1 && docker images | grep $DOCKER_IMAGE_NAME + image_tags=($(docker images | grep $DOCKER_IMAGE_NAME | awk '{{print $2}}')) + for tag in "${{image_tags[@]}}"; do + echo "Removing docker image $DOCKER_IMAGE_NAME:$tag..." + docker rmi $DOCKER_IMAGE_NAME:$tag + done fi # Start the build -echo "Building of $DOCKER_IMAGE_NAME:$DOCKER_TAG..." +echo "Building docker image: $DOCKER_IMAGE_NAME:$DOCKER_TAG..." cd $WORKSPACE/docker docker build -t $DOCKER_IMAGE_NAME:$DOCKER_TAG . echo "Creating tag 'latest'..." diff --git a/jjb/functest/functest.yml b/jjb/functest/functest.yml index 598bcf2a5..4df779d8c 100644 --- a/jjb/functest/functest.yml +++ b/jjb/functest/functest.yml @@ -226,10 +226,10 @@ artifactNumToKeep: -1 builders: + - 'functest-cleanup' - 'set-functest-env' - 'functest-all' - 'functest-store-results' - - 'functest-cleanup' - job-template: name: functest-{installer}-{stream} @@ -271,10 +271,10 @@ artifactNumToKeep: -1 builders: + - 'functest-cleanup' - 'set-functest-env' - 'functest-all' - 'functest-store-results' - - 'functest-cleanup' - job-template: name: functest-vims-{installer}-{stream} @@ -541,8 +541,7 @@ echo "Functest: Start Docker and prepare environment" envs="INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP}" - docker ps -a | grep opnfv/functest | awk '{print $1}' | xargs docker rm -f &>/dev/null - docker pull opnfv/functest + docker pull opnfv/functest:latest_stable echo "Functest: Running docker run command: docker run -i -e $envs opnfv/functest /bin/bash &" docker run -i -e $envs opnfv/functest /bin/bash & docker ps -a @@ -647,8 +646,7 @@ set +e # cleanup: remove any docker containers leftovers - echo "Removing the docker container..." + echo "Removing existing Functest Docker containers..." docker rm -f $(docker ps | grep opnfv/functest | awk '{print $1}') - echo "Removing the docker image..." + echo "Removing existing Functest Docker image..." docker rmi -f $(docker images | grep opnfv/functest | awk '{print $3}') - |