diff --git a/Jenkinsfile b/Jenkinsfile index 19270edb9d..1b98308ef6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -102,8 +102,8 @@ pipeline { } stage("${OS} Test") { - EVENT_PORT = OSList.indexOf(OS) + 4100 - sh "./deploy/build.sh --os=${OS} --test --eventport=${EVENT_PORT}" + network="jenkins-${EXECUTOR_NUMBER}-${OS}" + sh "./deploy/build.sh --os=${OS} --test --dockernetwork=${network}" } } } diff --git a/deploy/build.sh b/deploy/build.sh index 0380cd04a3..ffa3ce1414 100755 --- a/deploy/build.sh +++ b/deploy/build.sh @@ -177,6 +177,10 @@ OPTIONS before performing the build. If a docker image is not already present on the system it will automatically pulled from dockerhub even without the --dockerpull option. + + --dockernetwork + If specified, a docker network with this name will be created, + used for the docker container, and then removed. --keys=dir Specifies a directory containing signing keys and certificates @@ -356,6 +360,9 @@ parsecmd() { --dockerfile=*) eval "DOCKERFILE=${i#*=}" ;; + --dockernetwork=*) + eval "DOCKERNETWORK=${i#*=}" + ;; --keys=*) eval "KEYS=${i#*=}" ;; @@ -644,6 +651,7 @@ OS=${OS} \ PUBLISHDIR=${PUBLISHDIR} \ DOCKERIMAGE=${DOCKERIMAGE} \ DOCKERFILE=${DOCKERFILE} \ + DOCKERNETWORK=${DOCKERNETWORK} \ KEYS=${KEYS} \ DISTNAME=${DISTNAME} \ UPDATEPKG=${UPDATEPKG} \ diff --git a/deploy/platform/platform_build.sh b/deploy/platform/platform_build.sh index 0266f6e0c9..cf5b158488 100755 --- a/deploy/platform/platform_build.sh +++ b/deploy/platform/platform_build.sh @@ -85,6 +85,9 @@ rundocker() { docker rm $(cat ${WORKSPACE}/${OS}_docker-cid) || true rm -f ${WORKSPACE}/${OS}_docker-cid fi + if [ ! -z $DOCKERNETWORK ]; then + docker network rm ${DOCKERNETWORK} || true + fi } function abort() { @@ -99,9 +102,13 @@ rundocker() { while [ $status = 127 -a $loop_count -lt 5 ]; do let loop_count=$loop_count+1 - kill_docker + network="" + if [ ! -z $DOCKERNETWORK ]; then + docker network create ${DOCKERNETWORK} + network="--network=${DOCKERNETWORK}" + fi - docker run --cap-add=SYS_PTRACE -t $stdio \ + docker run --cap-add=SYS_PTRACE -t $stdio $network \ --cidfile=${WORKSPACE}/${OS}_docker-cid \ -u $(id -u):$(id -g) --privileged -h $DISTNAME -e "srcdir=${DOCKER_SRCDIR}" \ -e "ARCH=${arch}" \ @@ -145,9 +152,10 @@ rundocker() { docker logs --follow $cid status=$(docker inspect $cid --format='{{.State.ExitCode}}') - - docker rm $cid fi + + kill_docker + done if [ ! "$status" = "0" ]; then RED