From b71367f051b3de262dd962d0a6c7737706abdbae Mon Sep 17 00:00:00 2001 From: "Greg L. Turnquist" Date: Tue, 3 Nov 2020 16:21:36 -0600 Subject: [PATCH] DATAREDIS-1220 - Migrate to running CI test jobs as root. To avoid permission issues with Redis, run the container as root. Apply proper measures so that maven caching doesn't break other users of the same agents. --- Jenkinsfile | 63 +++++------------------------------------------------ ci/test.sh | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+), 57 deletions(-) create mode 100755 ci/test.sh diff --git a/Jenkinsfile b/Jenkinsfile index 6048eaca5..118f206a6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -85,29 +85,12 @@ pipeline { docker { image 'springci/spring-data-openjdk8-with-redis-6.0:latest' label 'data' - args '-v $HOME/.m2:/tmp/jenkins-home/.m2' + args '-u root -v $HOME/.m2:/tmp/jenkins-home/.m2' } } options { timeout(time: 30, unit: 'MINUTES') } steps { - // Create link to directory with Redis binaries - sh 'ln -sf /work' - - // Launch Redis in proper configuration - sh 'make start' - - // Execute maven test - sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean test -DrunLongTests=true -U -B' - - // Capture resulting exit code from maven (pass/fail) - sh 'RESULT=\$?' - - // Shutdown Redis - sh 'make stop' - - // Return maven results - sh 'exit \$RESULT' - + sh 'PROFILE=none LONG_TESTS=true ci/test.sh' } } @@ -124,29 +107,12 @@ pipeline { docker { image 'springci/spring-data-openjdk11-with-redis-6.0:latest' label 'data' - args '-v $HOME/.m2:/tmp/jenkins-home/.m2' + args '-u root -v $HOME/.m2:/tmp/jenkins-home/.m2' } } options { timeout(time: 30, unit: 'MINUTES') } steps { - // Create link to directory with Redis binaries - sh 'ln -sf /work' - - // Launch Redis in proper configuration - sh 'make start' - - // Execute maven test - sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean test -U -B' - - // Capture resulting exit code from maven (pass/fail) - sh 'RESULT=\$?' - - // Shutdown Redis - sh 'make stop' - - // Return maven results - sh 'exit \$RESULT' - + sh 'PROFILE=java11 ci/test.sh' } } stage("test: baseline (jdk15)") { @@ -154,29 +120,12 @@ pipeline { docker { image 'springci/spring-data-openjdk15-with-redis-6.0:latest' label 'data' - args '-v $HOME/.m2:/tmp/jenkins-home/.m2' + args '-u root -v $HOME/.m2:/tmp/jenkins-home/.m2' } } options { timeout(time: 30, unit: 'MINUTES') } steps { - // Create link to directory with Redis binaries - sh 'ln -sf /work' - - // Launch Redis in proper configuration - sh 'make start' - - // Execute maven test - sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean test -U -B' - - // Capture resulting exit code from maven (pass/fail) - sh 'RESULT=\$?' - - // Shutdown Redis - sh 'make stop' - - // Return maven results - sh 'exit \$RESULT' - + sh 'PROFILE=java11 ci/test.sh' } } } diff --git a/ci/test.sh b/ci/test.sh new file mode 100755 index 000000000..9d7f117a8 --- /dev/null +++ b/ci/test.sh @@ -0,0 +1,23 @@ +#!/bin/bash -x + +set -euo pipefail + +rm -f work + +# Create link to directory with Redis binaries +cwd=$(pwd) + +# Launch Redis in proper configuration +pushd / && make -f $cwd/Makefile start && popd + +# Execute maven test +MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean test -P${PROFILE} -DrunLongTests=${LONG_TESTS:-false} -U -B -Dmaven.repo.local=/tmp/jenkins-home/.m2/spring-data-redis + +# Capture resulting exit code from maven (pass/fail) +RESULT=$? + +# Shutdown Redis +pushd / && make -f $cwd/Makefile stop && popd + +# Return maven results +exit $RESULT \ No newline at end of file