-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
231 lines (209 loc) · 7.54 KB
/
Jenkinsfile
File metadata and controls
231 lines (209 loc) · 7.54 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
221
222
223
224
225
226
227
228
229
230
231
#!groovy
library "knime-pipeline@$DEFAULT_LIBRARY_VERSION"
properties([
pipelineTriggers([
upstream("knime-workbench/${env.BRANCH_NAME.replaceAll('/', '%2F')}" +
", knime-kerberos/${env.BRANCH_NAME.replaceAll('/', '%2F')}")
]),
parameters(workflowTests.getConfigurationsAsParameters()),
buildDiscarder(logRotator(numToKeepStr: '5')),
disableConcurrentBuilds()
])
String ecrPrefix = '910065342149.dkr.ecr.eu-west-1.amazonaws.com/'
buildConfigurations = [
Tycho: {
node('maven && java21 && medium') {
knimetools.defaultTychoBuild(updateSiteProject: 'org.knime.update.database')
owasp.sendNodeJSSBOMs(readMavenPom(file: 'pom.xml').properties['revision'])
}
},
InMemory: {
inMemoryDbTest()
},
Postgres: {
dbTest(
dbName: 'postgres',
containerImage: ecrPrefix + 'knime/postgres:12',
envArgs: ['POSTGRES_USER=knime01', 'POSTGRES_PASSWORD=password'],
ports: [5432],
)
},
Mysql5: {
dbTest(
dbName: 'mysql.5',
genericName: 'mysql',
containerImage: ecrPrefix + 'knime/mysql5',
envArgs: ['MYSQL_ROOT_PASSWORD=root', 'MYSQL_DATABASE=knime01', 'MYSQL_USER=knime01', 'MYSQL_PASSWORD=password' ],
ports: [3306],
)
},
Mysql8: {
dbTest(
dbName: 'mysql.8',
genericName: 'mysql',
containerImage: ecrPrefix + 'knime/mysql8',
envArgs: [ 'MYSQL_ROOT_PASSWORD=root', 'MYSQL_DATABASE=knime01', 'MYSQL_USER=knime01', 'MYSQL_PASSWORD=password' ],
port: [3306],
)
},
Mysql8Deprecated: {
dbTest(
dbName: 'mysql.8.deprecated',
genericName: 'mysql',
containerImage: ecrPrefix + 'knime/mysql8',
envArgs: [ 'MYSQL_ROOT_PASSWORD=root', 'MYSQL_DATABASE=knime01', 'MYSQL_USER=knime01', 'MYSQL_PASSWORD=password' ],
port: [3306],
)
},
]
try {
// parallel build steps
parallel buildConfigurations
withEnv([ 'KNIME_POSTGRES_USER=knime01', 'KNIME_POSTGRES_PASSWORD=password',
'KNIME_MYSQL_USER=root', 'KNIME_MYSQL_PASSWORD=password'
]) {
workflowTests.runTests(
dependencies: [
repositories: [
'knime-cef',
'knime-credentials-base',
'knime-database',
'knime-kerberos',
'knime-testing-internal',
'knime-filehandling',
'knime-gateway',
'knime-hubclient-sdk',
'knime-jep',
'knime-chemistry',
'knime-python',
'knime-stats',
'knime-datageneration',
'knime-pmml-translation',
'knime-timeseries',
'knime-distance',
'knime-jfreechart',
'knime-virtual',
'knime-excel',
'knime-js-base',
'knime-ensembles',
'knime-office365',
'knime-expressions',
'knime-streaming',
]
],
sidecarContainers: [
[ image: "${dockerTools.ECR}/knime/postgres:12", namePrefix: 'POSTGRES', port: 5432,
envArgs: [
"POSTGRES_USER=${env.KNIME_POSTGRES_USER}", "POSTGRES_PASSWORD=${env.KNIME_POSTGRES_PASSWORD}",
'POSTGRES_DB=knime_testing'
]
],
[ image: "${dockerTools.ECR}/knime/mysql5", namePrefix: 'MYSQL', port: 3306,
envArgs: ["MYSQL_ROOT_PASSWORD=${env.KNIME_MYSQL_PASSWORD}"]
]
]
)
}
// finally: run sonarqube
stage('Sonarqube analysis') {
env.lastStage = env.STAGE_NAME
configs = workflowTests.ALL_CONFIGURATIONS.collect() + ['mysql.5', 'mysql.8', 'mysql.8.deprecated', 'postgres', 'in-memory-dbs']
workflowTests.runSonar(stashes: configs, withOutNode: false)
}
} catch (ex) {
currentBuild.result = 'FAILURE'
throw ex
} finally {
notifications.notifyBuild(currentBuild.result)
}
// build function definitions
void collectCoverageData(String dbName) {
withEnv(["DB_NAME=${dbName}"]) {
sh(script: '''
dirs_with_runs=$(find . -name jacoco*.exec -exec dirname {} \\;)
# copy coverage.xml to root dir for non-empty reports
if [[ -n $dirs_with_runs ]]; then
reports=$(find . -name jacoco.xml | grep "${dirs_with_runs}" | cut -c3-)
for r in $reports
do
cp "$r" "jacoco-junit-${DB_NAME}-${r//\\//-}"
done
fi
''', label: 'collect coverage files')
}
// stash coverage data
stash name: dbName, includes: 'jacoco-*.xml'
}
void inMemoryDbTest() {
node('maven && java21 && medium') {
try {
// Run verification
stage('Testing in memory databases') {
env.lastStage = env.STAGE_NAME
checkout scm
withMaven(options: [artifactsPublisher(disabled: true)]) {
withCredentials([usernamePassword(credentialsId: 'ARTIFACTORY_CREDENTIALS', passwordVariable: 'ARTIFACTORY_PASSWORD', usernameVariable: 'ARTIFACTORY_LOGIN')]) {
String testParams = '-Dknime.h2.enable=true -Dknime.sqlite.enable=true -Dknime.msaccess.enable=true'
knimetools.materializeResources(['common.inc', 'scripts/tycho.inc'])
withEnv(["TEST_PARAMS=${testParams}"]) {
sh(
script: 'mvn -Dmaven.test.failure.ignore=true -Dknime.p2.repo=${P2_REPO} ${TEST_PARAMS} clean verify -P test', label: 'run db tests'
)
}
collectCoverageData('in-memory-dbs')
// Collect test results
junit allowEmptyResults: true, testResults: '**/target/surefire-reports/TEST-*.xml'
}
}
}
} catch (ex) {
currentBuild.result = 'FAILURE'
throw ex
}
}
}
def dbTest(Map args = [:]) {
node('maven && java21 && medium') {
def sidecars = dockerTools.createSideCarFactory()
try {
// verification
stage("Testing: ${args.dbName}") {
env.lastStage = env.STAGE_NAME
checkout scm
String containerImage = args.containerImage
List envArgs = args.envArgs as List
String dbName = args.dbName
List ports = args.ports as List
def container = sidecars.createSideCar(containerImage, dbName, envArgs, ports).start()
withMaven(options: [artifactsPublisher(disabled: true)]) {
withCredentials([usernamePassword(credentialsId: 'ARTIFACTORY_CREDENTIALS', passwordVariable: 'ARTIFACTORY_PASSWORD', usernameVariable: 'ARTIFACTORY_LOGIN')]) {
// define maven properties to override
String testParams
if (args?.genericName) {
// we need to enable both the generic database and the specific subinstance, the host parameter is set to the generic property
testParams = "-Dknime.${args.genericName}.enable=true -Dknime.${args.genericName}.host=${container.getContainerIP()} -Dknime.${args.dbName}.enable=true "
} else {
// regular case, we can just enable the database and set the host parameter
testParams = "-Dknime.${args.dbName}.enable=true -Dknime.${args.dbName}.host=${container.getContainerIP()}"
}
withEnv(["TEST_PARAMS=${testParams}"]) {
sh(
script: 'mvn -Dmaven.test.failure.ignore=true -Dknime.p2.repo=${P2_REPO} ${TEST_PARAMS} clean verify -P test', label: 'run-db-tests'
)
}
collectCoverageData(dbName)
// Collect test results
junit allowEmptyResults: true, testResults: '**/target/surefire-reports/TEST-*.xml'
}
}
}
} catch (ex) {
currentBuild.result = 'FAILURE'
throw ex
} finally {
// Stop and remove all sidecar containers
sidecars.close()
}
}
}
/* vim: set shiftwidth=4 expandtab smarttab: */