-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathJenkinsfile
300 lines (273 loc) · 9.37 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
@Library('shared-libraries') _
def getJava(){
if(env.JAVA_VERSION=="JAVA17"){
return "/home/builder/java/jdk-17.0.2"
}else if(env.JAVA_VERSION=="JAVA11"){
return "/home/builder/java/jdk-11.0.2"
}else if(env.JAVA_VERSION=="JAVA21"){
return "/home/builder/java/jdk-21.0.1"
}else{
return "/home/builder/java/openjdk-1.8.0-262"
}
}
def setupDockerMarkLogic(String image){
sh label:'mlsetup', script: '''#!/bin/bash
echo "Removing any running MarkLogic server and clean up MarkLogic data directory"
sudo /usr/local/sbin/mladmin remove
sudo /usr/local/sbin/mladmin cleandata
cd java-client-api/test-app
docker compose down -v || true
docker volume prune -f
echo "Using image: "'''+image+'''
docker pull '''+image+'''
MARKLOGIC_IMAGE='''+image+''' MARKLOGIC_LOGS_VOLUME=marklogicLogs docker compose up -d --build
echo "mlPassword=admin" > gradle-local.properties
echo "Waiting for MarkLogic server to initialize."
sleep 60s
cd ..
echo "mlPassword=admin" > gradle-local.properties
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
./gradlew mlTestConnections
./gradlew -i mlDeploy mlReloadSchemas
'''
}
def runTests(String image) {
setupDockerMarkLogic(image)
sh label:'run marklogic-client-api tests', script: '''#!/bin/bash
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
cd java-client-api
mkdir -p marklogic-client-api/build/test-results/test
./gradlew marklogic-client-api:test || true
'''
sh label:'run ml-development-tools tests', script: '''#!/bin/bash
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
cd java-client-api
mkdir -p ml-development-tools/build/test-results/test
./gradlew ml-development-tools:test || true
'''
sh label:'run fragile functional tests', script: '''#!/bin/bash
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
cd java-client-api
./gradlew mlDeploy -PmlForestDataDirectory=/space
./gradlew marklogic-client-api-functionaltests:runFragileTests || true
'''
sh label:'run fast functional tests', script: '''#!/bin/bash
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
cd java-client-api
./gradlew marklogic-client-api-functionaltests:runFastFunctionalTests || true
'''
sh label:'run slow functional tests', script: '''#!/bin/bash
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
cd java-client-api
./gradlew marklogic-client-api-functionaltests:runSlowFunctionalTests || true
'''
postProcessTestResults()
}
def runTestsWithReverseProxy(String image) {
setupDockerMarkLogic(image)
sh label:'run fragile functional tests with reverse proxy', script: '''#!/bin/bash
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
cd java-client-api
./gradlew -PtestUseReverseProxyServer=true test-app:runReverseProxyServer marklogic-client-api-functionaltests:runFragileTests || true
'''
sh label:'run fast functional tests with reverse proxy', script: '''#!/bin/bash
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
cd java-client-api
./gradlew -PtestUseReverseProxyServer=true test-app:runReverseProxyServer marklogic-client-api-functionaltests:runFastFunctionalTests || true
'''
sh label:'run slow functional tests with reverse proxy', script: '''#!/bin/bash
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
cd java-client-api
./gradlew -PtestUseReverseProxyServer=true test-app:runReverseProxyServer marklogic-client-api-functionaltests:runSlowFunctionalTests || true
'''
postProcessTestResults()
}
def postProcessTestResults() {
sh label:'post-test-process', script: '''
cd java-client-api
mkdir -p marklogic-client-api-functionaltests/build/test-results/runFragileTests
mkdir -p marklogic-client-api-functionaltests/build/test-results/runFastFunctionalTests
mkdir -p marklogic-client-api-functionaltests/build/test-results/runSlowFunctionalTests
cd $WORKSPACE/java-client-api/marklogic-client-api/build/test-results/test/
sed -i "s/classname=\\"/classname=\\"${STAGE_NAME}-/g" TEST*.xml
cd $WORKSPACE/java-client-api/ml-development-tools/build/test-results/test/
sed -i "s/classname=\\"/classname=\\"${STAGE_NAME}-/g" TEST*.xml
cd $WORKSPACE/java-client-api/marklogic-client-api-functionaltests/build/test-results/runFragileTests/
sed -i "s/classname=\\"/classname=\\"${STAGE_NAME}-/g" TEST*.xml
cd $WORKSPACE/java-client-api/marklogic-client-api-functionaltests/build/test-results/runFastFunctionalTests/
sed -i "s/classname=\\"/classname=\\"${STAGE_NAME}-/g" TEST*.xml
cd $WORKSPACE/java-client-api/marklogic-client-api-functionaltests/build/test-results/runSlowFunctionalTests/
sed -i "s/classname=\\"/classname=\\"${STAGE_NAME}-/g" TEST*.xml
'''
}
def tearDownDocker() {
sh label:'tearDownDocker', script: '''#!/bin/bash
cd java-client-api/test-app
docker compose down -v || true
docker volume prune -f
'''
}
pipeline{
agent {label 'javaClientLinuxPool'}
options {
checkoutToSubdirectory 'java-client-api'
buildDiscarder logRotator(artifactDaysToKeepStr: '7', artifactNumToKeepStr: '', daysToKeepStr: '7', numToKeepStr: '10')
}
parameters {
booleanParam(name: 'regressions', defaultValue: false, description: 'indicator if build is for regressions')
string(name: 'Email', defaultValue: '' ,description: 'Who should I say send the email to?')
string(name: 'JAVA_VERSION', defaultValue: 'JAVA8' ,description: 'Who should I say send the email to?')
}
environment {
JAVA_HOME_DIR= getJava()
GRADLE_DIR =".gradle"
DMC_USER = credentials('MLBUILD_USER')
DMC_PASSWORD = credentials('MLBUILD_PASSWORD')
}
stages {
stage('pull-request-tests') {
when {
not {
expression {return params.regressions}
}
}
steps {
setupDockerMarkLogic("ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-12")
sh label:'run marklogic-client-api tests', script: '''#!/bin/bash
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
cd java-client-api
./gradlew cleanTest marklogic-client-api:test
./gradlew -PtestUseReverseProxyServer=true test-app:runReverseProxyServer marklogic-client-api-functionaltests:runFastFunctionalTests || true
'''
junit '**/build/**/TEST*.xml'
}
post {
always {
tearDownDocker()
}
}
}
stage('publish'){
when {
branch 'develop'
not {
expression {return params.regressions}
}
}
steps{
sh label:'publish', script: '''#!/bin/bash
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
cp ~/.gradle/gradle.properties $GRADLE_USER_HOME;
cd java-client-api
./gradlew publish
'''
}
}
stage('regressions-11.2.0') {
when {
allOf {
branch 'develop'
expression {return params.regressions}
}
}
steps {
runTests("ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:11.2.0-ubi")
junit '**/build/**/TEST*.xml'
}
post {
always {
tearDownDocker()
}
}
}
stage('regressions-11') {
when {
allOf {
branch 'develop'
expression {return params.regressions}
}
}
steps {
runTests("ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-11")
junit '**/build/**/TEST*.xml'
}
post {
always {
tearDownDocker()
}
}
}
stage('regressions-11-reverseProxy') {
when {
allOf {
branch 'develop'
expression {return params.regressions}
}
}
steps {
runTestsWithReverseProxy("ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-11")
junit '**/build/**/TEST*.xml'
}
post {
always {
tearDownDocker()
}
}
}
stage('regressions-12') {
when {
allOf {
branch 'develop'
expression {return params.regressions}
}
}
steps {
runTests("ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-12")
junit '**/build/**/TEST*.xml'
}
post {
always {
tearDownDocker()
}
}
}
stage('regressions-10.0') {
when {
allOf {
branch 'develop'
expression {return params.regressions}
}
}
steps {
runTests("ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-10")
junit '**/build/**/TEST*.xml'
}
post {
always {
tearDownDocker()
}
}
}
}
}