Skip to content

Commit b71367f

Browse files
committed
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.
1 parent 2894944 commit b71367f

File tree

2 files changed

+29
-57
lines changed

2 files changed

+29
-57
lines changed

Jenkinsfile

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -85,29 +85,12 @@ pipeline {
8585
docker {
8686
image 'springci/spring-data-openjdk8-with-redis-6.0:latest'
8787
label 'data'
88-
args '-v $HOME/.m2:/tmp/jenkins-home/.m2'
88+
args '-u root -v $HOME/.m2:/tmp/jenkins-home/.m2'
8989
}
9090
}
9191
options { timeout(time: 30, unit: 'MINUTES') }
9292
steps {
93-
// Create link to directory with Redis binaries
94-
sh 'ln -sf /work'
95-
96-
// Launch Redis in proper configuration
97-
sh 'make start'
98-
99-
// Execute maven test
100-
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean test -DrunLongTests=true -U -B'
101-
102-
// Capture resulting exit code from maven (pass/fail)
103-
sh 'RESULT=\$?'
104-
105-
// Shutdown Redis
106-
sh 'make stop'
107-
108-
// Return maven results
109-
sh 'exit \$RESULT'
110-
93+
sh 'PROFILE=none LONG_TESTS=true ci/test.sh'
11194
}
11295
}
11396

@@ -124,59 +107,25 @@ pipeline {
124107
docker {
125108
image 'springci/spring-data-openjdk11-with-redis-6.0:latest'
126109
label 'data'
127-
args '-v $HOME/.m2:/tmp/jenkins-home/.m2'
110+
args '-u root -v $HOME/.m2:/tmp/jenkins-home/.m2'
128111
}
129112
}
130113
options { timeout(time: 30, unit: 'MINUTES') }
131114
steps {
132-
// Create link to directory with Redis binaries
133-
sh 'ln -sf /work'
134-
135-
// Launch Redis in proper configuration
136-
sh 'make start'
137-
138-
// Execute maven test
139-
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean test -U -B'
140-
141-
// Capture resulting exit code from maven (pass/fail)
142-
sh 'RESULT=\$?'
143-
144-
// Shutdown Redis
145-
sh 'make stop'
146-
147-
// Return maven results
148-
sh 'exit \$RESULT'
149-
115+
sh 'PROFILE=java11 ci/test.sh'
150116
}
151117
}
152118
stage("test: baseline (jdk15)") {
153119
agent {
154120
docker {
155121
image 'springci/spring-data-openjdk15-with-redis-6.0:latest'
156122
label 'data'
157-
args '-v $HOME/.m2:/tmp/jenkins-home/.m2'
123+
args '-u root -v $HOME/.m2:/tmp/jenkins-home/.m2'
158124
}
159125
}
160126
options { timeout(time: 30, unit: 'MINUTES') }
161127
steps {
162-
// Create link to directory with Redis binaries
163-
sh 'ln -sf /work'
164-
165-
// Launch Redis in proper configuration
166-
sh 'make start'
167-
168-
// Execute maven test
169-
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean test -U -B'
170-
171-
// Capture resulting exit code from maven (pass/fail)
172-
sh 'RESULT=\$?'
173-
174-
// Shutdown Redis
175-
sh 'make stop'
176-
177-
// Return maven results
178-
sh 'exit \$RESULT'
179-
128+
sh 'PROFILE=java11 ci/test.sh'
180129
}
181130
}
182131
}

ci/test.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash -x
2+
3+
set -euo pipefail
4+
5+
rm -f work
6+
7+
# Create link to directory with Redis binaries
8+
cwd=$(pwd)
9+
10+
# Launch Redis in proper configuration
11+
pushd / && make -f $cwd/Makefile start && popd
12+
13+
# Execute maven test
14+
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
15+
16+
# Capture resulting exit code from maven (pass/fail)
17+
RESULT=$?
18+
19+
# Shutdown Redis
20+
pushd / && make -f $cwd/Makefile stop && popd
21+
22+
# Return maven results
23+
exit $RESULT

0 commit comments

Comments
 (0)