-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathJenkinsfile
More file actions
220 lines (196 loc) · 7.03 KB
/
Copy pathJenkinsfile
File metadata and controls
220 lines (196 loc) · 7.03 KB
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
@Library('shared-libraries') _
def runTests() {
sh label: 'deploy-test-app-and-run-tests', script: '''
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$JAVA_HOME/bin:${NODE_HOME_DIR}/bin:$PATH
cd node-client-api
node --version
npm --version
npm ci
cd test-app
./gradlew -i mlWaitTillReady
sleep 3
./gradlew -i mlWaitTillReady
./gradlew -i mlTestConnections
./gradlew -i mlDeploy
cd ..
rm -rf $WORKSPACE/*.xml || true
./node_modules/.bin/mocha --timeout 10000 -R xunit test-basic/ --reporter mocha-junit-reporter --reporter-options mochaFile=$WORKSPACE/test-basic-reports.xml || true
./node_modules/.bin/gulp setupProxyTests || true
./node_modules/.bin/mocha --timeout 10000 -R xunit test-basic-proxy/lib/**/*.js --reporter mocha-junit-reporter --reporter-options mochaFile=$WORKSPACE/test-basic-proxy-reports.xml || true
'''
junit '**/*.xml'
}
def runDockerCompose(String markLogicDockerImage) {
cleanupDocker()
sh label: 'run-docker-compose', script: '''#!/bin/bash
echo "Removing any running MarkLogic server and clean up MarkLogic data directory"
sudo /usr/local/sbin/mladmin remove
docker-compose down -v || true
sudo /usr/local/sbin/mladmin cleandata
cd node-client-api
echo "Running docker compose with MarkLogic image: ''' + markLogicDockerImage + '''"
MARKLOGIC_LOGS_VOLUME=/tmp MARKLOGIC_IMAGE=''' + markLogicDockerImage + ''' docker-compose up -d --build
'''
}
def teardownAfterTests() {
updateWorkspacePermissions()
sh label: 'teardown-docker', script: '''#!/bin/bash
cd node-client-api
docker-compose down -v || true
'''
cleanupDocker()
}
def runAuditReport() {
sh label: 'run-audit-report', script: '''
export PATH=${NODE_HOME_DIR}/bin:$PATH
cd node-client-api
npm ci
rm -rf $WORKSPACE/npm-audit-report.json || true
npm audit --audit-level=low --json > $WORKSPACE/npm-audit-report.json
'''
}
// For now, only failing on errors. See eslint.config.js for the lint configuration.
def runLint() {
sh label: 'run-lint', script: '''
export PATH=${NODE_HOME_DIR}/bin:$PATH
cd node-client-api
npm ci
npm run lint -- --quiet
'''
}
def runE2ETests() {
sh label: 'run-e2e-tests', script: '''
export JAVA_HOME=$JAVA_HOME_DIR
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
export PATH=$JAVA_HOME/bin:${NODE_HOME_DIR}/bin:$PATH
cd node-client-api
node --version
npm --version
npm ci
cd test-complete-app-mlDeploy
echo "Deploying from test-complete-app-mlDeploy"
./gradlew -i mlDeploy
cd ..
echo "Running test-complete tests"
./node_modules/.bin/mocha --no-parallel -R xunit --timeout 60000 test-complete/ --reporter mocha-junit-reporter --reporter-options mochaFile=$WORKSPACE/test-complete-results.xml || true
echo "Done with test-complete tests"
cd test-complete-proxy
npm install gulp-cli
gulp loadToModulesDB
gulp generateFnClasses
gulp copyFnClasses
# Adding sleep for the gulp commands to complete.
sleep 30
cp *.js ../test-complete/
cp -R ml-modules/ ../test-complete
cd ../test-complete
../node_modules/.bin/mocha -R xunit --timeout 60000 nodejs-ds-setup-docs.js
../node_modules/.bin/mocha -R xunit --timeout 60000 "nodejs-ds-required-params.js" --reporter mocha-junit-reporter --reporter-options mochaFile=$WORKSPACE/ds-required-params-results.xml || true
../node_modules/.bin/mocha -R xunit --timeout 60000 "nodejs-ds-error-map.js" --reporter mocha-junit-reporter --reporter-options mochaFile=$WORKSPACE/ds-multipleWorker-results.xml || true
# Disabling this for now, failing with the new all-mlDeploy setup for unknown reasons.
# ../node_modules/.bin/mocha -R xunit --timeout 60000 -R xunit "nodejs-ds-multipleWorker.js" --reporter mocha-junit-reporter --reporter-options mochaFile=$WORKSPACE/ds-multipleWorker-results.xml || true
../node_modules/.bin/mocha -R xunit --timeout 60000 -R xunit "nodejs-ds-transactions.js" --reporter mocha-junit-reporter --reporter-options mochaFile=$WORKSPACE/ds-transactions-results.js.xml || true
../node_modules/.bin/mocha -R xunit --timeout 60000 -R xunit "nodejs-ds-dynamic.js" --reporter mocha-junit-reporter --reporter-options mochaFile=$WORKSPACE/ds-dynamic-results.xml || true
'''
junit '**/*.xml'
}
pipeline {
agent none
triggers {
parameterizedCron(env.BRANCH_NAME == "develop" ? "00 02 * * * % regressions=true" : "")
}
parameters {
booleanParam(name: 'regressions', defaultValue: false, description: 'indicator if build is for regressions')
}
options {
checkoutToSubdirectory 'node-client-api'
buildDiscarder logRotator(artifactDaysToKeepStr: '7', artifactNumToKeepStr: '', daysToKeepStr: '7', numToKeepStr: '10')
}
environment {
NODE_HOME_DIR = "/users/ml/builder/nodeJs/node-v22.20.0-linux-x64"
DMC_USER = credentials('MLBUILD_USER')
DMC_PASSWORD = credentials('MLBUILD_PASSWORD')
GRADLE_DIR = ".gradle"
JAVA_HOME_DIR = "/home/builder/java/jdk-17.0.2"
}
stages {
stage('pull-request-tests') {
agent { label 'nodeclientpool' }
steps {
runAuditReport()
runLint()
runDockerCompose('ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-12')
runTests()
runE2ETests()
}
post {
always {
teardownAfterTests()
}
}
}
stage('regressions') {
parallel {
stage('runtests-11-nightly') {
when {
allOf {
branch 'develop'
expression { return params.regressions }
}
}
agent { label 'nodeclientpool' }
steps {
runDockerCompose('ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-11')
runTests()
runE2ETests()
}
post {
always {
teardownAfterTests()
}
}
}
stage('runtests-12-nightly') {
when {
allOf {
branch 'develop'
expression { return params.regressions }
}
}
agent { label 'nodeclientpool' }
steps {
runDockerCompose('ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-12')
runTests()
runE2ETests()
}
post {
always {
teardownAfterTests()
}
}
}
stage('runtests-10-nightly') {
when {
allOf {
branch 'develop'
expression { return params.regressions }
}
}
agent { label 'nodeclientpool' }
steps {
runDockerCompose('ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-10')
runTests()
runE2ETests()
}
post {
always {
teardownAfterTests()
}
}
}
}
}
}
}