forked from modelon-community/fmi-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.groovy
200 lines (176 loc) · 5.44 KB
/
Jenkinsfile.groovy
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
// Node requirements:
// VisualStudio2017: C compiler
// OCT-SDK-1.6.2: CMake, msys
// docker: docker
def Configs = [
'win64': [
name: 'win64',
os: 'windows',
node: 'VisualStudio2017 && OCT-SDK-1.6.2',
target_install: 'install',
target_test: 'test'
],
'win64_static_runtime': [
name: 'win64_static_runtime',
os: 'windows',
node: 'VisualStudio2017 && OCT-SDK-1.6.2',
target_install: 'install',
target_test: 'test'
],
'mingw_w64': [
name: 'mingw_w64',
os: 'windows',
node: 'VisualStudio2017 && OCT-SDK-1.6.2',
target_install: 'install',
target_test: 'test'
],
'centos64': [
name: 'centos64',
os: 'linux',
node: 'docker',
target_install: '-C . -f build/docker/Makefile install',
target_test: '-C . -f build/docker/Makefile test'
],
'ubuntu64': [
name: 'ubuntu64',
os: 'linux',
node: 'docker',
target_install: '-C . -f build/docker/Makefile install',
target_test: '-C . -f build/docker/Makefile test'
],
'documentation': [
name: 'documentation',
os: 'linux',
node: 'docker',
target_install: '-C . -f build/docker/Makefile documentation',
target_test: 'N/A'
]
]
def tasks = [:]
// for (conf_entry in Configs) // This doesn't work, causes SerializationError for the Map
Configs.each { conf_entry ->
def conf = conf_entry.value // bind variable before use in closure
tasks[conf.name] = {
node(conf.node) {
def testLogDir = "build_${conf.name}/Testing/Temporary"
def installDir = "install_${conf.name}"
stage("Checkout: ${conf.name}") {
checkout scm
fixFilePermissions(conf.os)
}
stage("Clean artifacts: ${conf.name}") {
clean(conf)
}
stage("Build: ${conf.name}") {
build(conf)
}
stage("Test: ${conf.name}") {
test(conf, testLogDir)
}
stage("Archive: ${conf.name}") {
archiveArtifacts(artifacts: "${installDir}/**")
archiveArtifacts(artifacts: "${testLogDir}/**")
}
}
}
}
def conf = Configs['documentation']
tasks[conf.name] = {
node(conf.node) {
stage("Checkout: ${conf.name}") {
checkout scm
fixFilePermissions(conf.os)
}
stage("Clean artifacts: ${conf.name}") {
clean(conf)
}
stage("Build: ${conf.name}") {
build(conf)
}
stage("Archive: ${conf.name}") {
archiveArtifacts(artifacts: "install_${conf.name}/doc/html/**")
}
}
}
// Currently getting cygwin heap error when parallellizing win64 and win64_static_runtime, so not doing that for now
def parallellTasks = [
'centos64': tasks.centos64,
'ubuntu64': tasks.ubuntu64,
'mingw_w64': tasks.mingw_w64,
'win64': tasks.win64,
'documentation': tasks.documentation,
]
parallel parallellTasks
tasks.win64_static_runtime()
def clean(conf) {
if (conf.os == 'windows') {
bat """
call build\\setenv.bat
make clean
"""
} else if (conf.os == 'linux') {
sh """
make clean
"""
} else {
error(message: "Invalid configuration operating system: ${conf.os}")
}
}
def build(conf) {
if (conf.os == 'windows') {
bat """
call build\\setenv.bat
make ${conf.target_install} CONFIG_FILE=build/config/${conf.name}
"""
} else if (conf.os == 'linux') {
sh """
make ${conf.target_install} CONFIG_FILE=build/config/${conf.name}
"""
} else {
error(message: "Invalid configuration operating system: ${conf.os}")
}
}
def test(conf, testLogDir) {
def res // exit code
if (conf.os == 'windows') {
res = bat(returnStatus: true, script: """
call build\\setenv.bat
make ${conf.target_test} CONFIG_FILE=build/config/${conf.name}
""")
} else if (conf.os == 'linux') {
res = sh(returnStatus: true, script: """
make ${conf.target_test} CONFIG_FILE=build/config/${conf.name}
""")
} else {
error(message: "Invalid config operating system: ${conf.os}")
}
if (res) {
setBuildStatus('UNSTABLE', "Test failure. Exit code from ctest: ${res}")
}
dir(testLogDir) {
if (fileExists("LastTestsFailed.log")) {
setBuildStatus('UNSTABLE', "Failing tests: ${testLogDir}/LastTestsFailed.log)")
}
// The test log has different names if we run memcheck or not, but this file should
// always exist if we run tests:
if (!fileExists("CTestCostData.txt")) {
setBuildStatus('UNSTABLE', 'File CTestCostData.txt is missing - perhaps tests were not run?')
}
}
}
def setBuildStatus(status, msg) {
currentBuild.result = status
println("Build result manually set to ${status}. Reason:\n${msg}")
}
def fixFilePermissions(os) {
if (os == 'linux') {
sh """
# Allow internal docker script to run
chmod a+x build/docker/build.sh
# Allow copying artifacts to host
chmod 777 .
# All the other scripts we need to run...
chmod a+x Test/scripts/verify_memcheck_logs.sh
"""
}
}