-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile
311 lines (284 loc) · 9.84 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
301
302
303
304
305
306
307
308
309
310
311
#!groovy
def BN = (BRANCH_NAME == 'master' || BRANCH_NAME.startsWith('releases/')) ? BRANCH_NAME : 'releases/2025-07'
@groovy.transform.Field
static final String[] PYTHON_VERSIONS = ['36', '37', '38']
@groovy.transform.Field
static final String DEFAULT_PYTHON_VERSION = '36'
library "knime-pipeline@$BN"
def baseBranch = (BN == KNIMEConstants.NEXT_RELEASE_BRANCH ? "master" : BN.replace("releases/",""))
properties([
pipelineTriggers([
upstream('knime-filehandling/' + env.BRANCH_NAME.replaceAll('/', '%2F'))
]),
parameters(workflowTests.getConfigurationsAsParameters() + getPythonParameters()),
buildDiscarder(logRotator(numToKeepStr: '5')),
disableConcurrentBuilds()
])
/*
* Windows Enviroments
*/
@groovy.transform.Field
static final String[] PYTHON_WIN_64_ENV = [
'py27_knime',
'py36_knime',
'py36_knime_dl_cpu',
'py36_knime_dl_gpu',
'py36_knime_tf2_cpu',
'py36_knime_tf2_gpu',
'py37_knime',
'py37_knime_dl_cpu',
'py38_knime',
'py38_knime_tf2_cpu',
'py39_knime_tf2_cpu',
'py39_knime',
]
/*
* MacOS Enviroments
*/
@groovy.transform.Field
static final String[] PYTHON_MAC_64_ENV = [
'py27_knime',
'py36_knime_dl_cpu',
'py36_knime_tf2_cpu',
'py36_knime',
'py37_knime_dl_cpu',
'py37_knime',
'py38_knime_tf2_cpu',
'py38_knime',
'py39_knime_tf2_cpu',
'py39_knime'
]
/*
* Linux Enviroments
*/
@groovy.transform.Field
static final String[] PYTHON_LINUX_ENV = [
'py27_knime',
'py36_knime_dl_cpu',
'py36_knime_dl_gpu',
'py36_knime_tf2_cpu',
'py36_knime_tf2_gpu',
'py38_knime',
'py38_knime_tf2_cpu',
'py39_knime',
'py39_knime_tf2_cpu'
]
try {
knimetools.defaultTychoBuild('org.knime.update.python.legacy', 'maven && python2 && python3 && java17')
if (params.testEnvironmentCreation) {
// Build in Sequence for MacOS
node('macosx && workflow-tests && python3') {
for (envFile in PYTHON_MAC_64_ENV) {
String envString = new String(envFile)
buildCondaEnvironmentMac(envString)
}
}
def osBuild = [:]
// Linux
for (envFile in PYTHON_LINUX_ENV) {
String envString = new String(envFile)
osBuild["${envString}-LINUX"] = {
buildCondaEnvironmentLinux(envString)
}
}
// Windows
for (envFile in PYTHON_WIN_64_ENV) {
String envString = new String(envFile)
osBuild["${envString}-WIN"] = {
buildCondaEnvironmentWin(envString)
}
}
// run all in parallel
parallel(osBuild)
}
def parallelConfigs = [:]
for (py in PYTHON_VERSIONS) {
if (params[py]) {
// need to create a deep copy here, otherwise Jenkins will use
// the last selected option for everything
def python_version = new String(py)
parallelConfigs["${python_version}"] = {
runPython3MultiversionWorkflowTestConfig(python_version, baseBranch)
}
}
}
// legacy tests
parallelConfigs["Python 2.7"] = {
runPython27WorkflowTests(baseBranch)
}
parallel(parallelConfigs)
stage('Sonarqube analysis') {
env.lastStage = env.STAGE_NAME
workflowTests.runSonar()
}
} catch (ex) {
currentBuild.result = 'FAILURE'
throw ex
} finally {
notifications.notifyBuild(currentBuild.result);
}
def buildCondaEnvironmentMac(String envFile) {
String ymlPath = "org.knime.python2.envconfigs/envconfigs/macos"
stage("$envFile MacOS") {
env.lastStage = env.STAGE_NAME
checkout scm
sh(
label: "Info",
script: """#!/bin/sh
conda info
"""
)
sh(
label: "Install $envFile",
script: """#!/bin/sh
conda env create -f $ymlPath/${envFile}.yml -p $WORKSPACE/$envFile --quiet --json --solver=classic
"""
)
sh(
label: "List $envFile",
script: """#!/bin/sh
conda list -p $WORKSPACE/$envFile
"""
)
}
}
def buildCondaEnvironmentWin(String envFile) {
//
String ymlPath = "org.knime.python2.envconfigs/envconfigs/windows"
String condaPath = "C:/Users/jenkins/Miniconda3/condabin/conda.bat"
node('windows && workflow-tests && python3') {
//
stage("$envFile") {
env.lastStage = env.STAGE_NAME
checkout scm
withEnv([
"ENV_FILE=$envFile",
"YML_PATH=$ymlPath",
"CONDA_PATH=$condaPath"]) {
sh 'sh $WORKSPACE\\\\run_conda_install.sh'
}
}
}
}
def buildCondaEnvironmentLinux(String envFile) {
node('ubuntu22.04 && python3 && workflow-tests') {
String ymlPath = "$WORKSPACE/org.knime.python2.envconfigs/envconfigs/linux"
stage("$envFile") {
env.lastStage = env.STAGE_NAME
checkout scm
sh(
label: 'Info',
script: """#!/bin/sh
. ~/miniconda3/etc/profile.d/conda.sh
conda info
"""
)
sh(
label: "Install $envFile",
script: """#!/bin/sh
. ~/miniconda3/etc/profile.d/conda.sh
conda env create -f $ymlPath/${envFile}.yml -p $WORKSPACE/$envFile --quiet --json --solver=classic
"""
)
sh(
label: "List $envFile",
script: """#!/bin/sh
. ~/miniconda3/etc/profile.d/conda.sh
conda list -p $WORKSPACE/$envFile
"""
)
}
}
}
/**
* Return parameters to select python version to run workflowtests with
*/
def getPythonParameters() {
def pythonParams = []
for (c in PYTHON_VERSIONS) {
pythonParams += booleanParam(defaultValue: c == DEFAULT_PYTHON_VERSION, description: "Run workflowtests with Python ${c}", name: c)
}
pythonParams += booleanParam(defaultValue: false, description: "Test Conda Environment creation on all OS", name: "testEnvironmentCreation")
return pythonParams
}
def runPython27WorkflowTests(String baseBranch){
withEnv([ "KNIME_POSTGRES_USER=knime01", "KNIME_POSTGRES_PASSWORD=password",
"KNIME_MYSQL_USER=root", "KNIME_MYSQL_PASSWORD=password",
"KNIME_MSSQLSERVER_USER=sa", "KNIME_MSSQLSERVER_PASSWORD=@SaPassword123",]){
workflowTests.runTests(
testflowsDir: "Testflows (${baseBranch})/knime-python-legacy/python2.7",
dependencies: [
repositories: [
'knime-chemistry',
'knime-python',
'knime-credentials-base',
'knime-database',
'knime-gateway',
'knime-office365',
'knime-datageneration',
'knime-distance',
'knime-ensembles',
'knime-filehandling',
'knime-jep',
'knime-jfreechart',
'knime-js-base',
'knime-kerberos',
'knime-python-legacy',
'knime-core-columnar',
'knime-testing-internal',
'knime-xml',
'knime-conda'
],
ius: [ 'org.knime.features.ext.jython.feature.group', 'org.knime.features.chem.types.feature.group' ]
],
extraNodeLabel: 'python2',
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}"]
],
[ image: "${dockerTools.ECR}/knime/mssql-server", namePrefix: "MSSQLSERVER", port: 1433,
envArgs: ["ACCEPT_EULA=Y", "SA_PASSWORD=${env.KNIME_MSSQLSERVER_PASSWORD}", "MSSQL_DB=knime_testing"]
]
],
)
}
}
def runPython3MultiversionWorkflowTestConfig(String pythonVersion, String baseBranch) {
withEnv([ "KNIME_WORKFLOWTEST_PYTHON_VERSION=${pythonVersion}" ]) {
stage("Workflowtests with Python: ${pythonVersion}") {
workflowTests.runTests(
testflowsDir: "Testflows (${baseBranch})/knime-python-legacy/python3.multiversion",
dependencies: [
repositories: [
'knime-chemistry',
'knime-python',
'knime-database',
'knime-office365',
'knime-datageneration',
'knime-distance',
'knime-ensembles',
'knime-filehandling',
'knime-jep',
'knime-jfreechart',
'knime-js-base',
'knime-kerberos',
'knime-python-legacy',
'knime-core-columnar',
'knime-testing-internal',
'knime-xml',
'knime-conda'
],
ius: [ 'org.knime.features.chem.types.feature.group' ]
],
extraNodeLabel: 'python-all'
)
}
}
}
/* vim: set shiftwidth=4 expandtab smarttab: */