-
Notifications
You must be signed in to change notification settings - Fork 237
/
Jenkinsfile
251 lines (231 loc) · 8.12 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
#!groovy
// load library https://github.com/tjhei/jenkins-stuff to provide
// killold.killOldBuilds() function:
@Library('tjhei') _
pipeline {
agent none
options {
timeout(time: 3, unit: 'HOURS')
}
stages
{
stage("abort old")
{
agent none
steps
{
githubNotify context: 'Jenkins', description: 'initializing...', status: 'PENDING'
// kill older builds in this PR:
script { killold.killOldBuilds() }
}
}
stage("main")
{
agent
{
// first build a docker image for running the tests from the repo
docker {
image 'geodynamics/aspect-tester:focal-dealii-9.5-v3'
// We mount /repos into the docker image. This allows us to cache
// the git repo by setting "advanced clone behaviors". If the
// directory does not exist, this will be ignored.
args '-v /repos:/repos:ro'
}
}
post { cleanup { cleanWs() } }
stages {
stage ("Print Info") {
steps {
echo "PR: ${env.CHANGE_ID} - ${env.CHANGE_TITLE}"
echo "CHANGE_AUTHOR_EMAIL: ${env.CHANGE_AUTHOR_EMAIL}"
echo "CHANGE_AUTHOR: ${env.CHANGE_AUTHOR}"
echo "CHANGE_AUTHOR_DISPLAY_NAME: ${env.CHANGE_AUTHOR_DISPLAY_NAME}"
echo "building on node ${env.NODE_NAME}"
}
}
stage ("Check Permissions") {
when {
// check for "ready to test" if it is a PR and not by one of the people listed
allOf {
changeRequest()
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
not {changeRequest authorEmail: "[email protected]"}
}
}
steps {
// For /rebuild to work you need to:
// 1) select "issue comment" to be delivered in the github webhook setting
// 2) install "GitHub PR Comment Build Plugin" on Jenkins
// 3) in project settings select "add property" "Trigger build on pr comment" with
// the phrase ".*/rebuild.*" (without quotes)
sh '''
wget -q -O - https://api.github.com/repos/geodynamics/aspect/issues/${CHANGE_ID}/labels | grep 'ready to test' || \
{ echo "This commit will only be tested when it has the label 'ready to test'. Trigger a rebuild by adding a comment that contains '/rebuild'..."; exit 1; }
'''
}
post {
failure
{
githubNotify context: 'Jenkins', description: 'need ready to test label and /rebuild', status: 'PENDING'
script
{
currentBuild.result='NOT_BUILT'
}
}
}
}
stage('Check Indentation') {
steps {
sh './contrib/utilities/indent'
sh 'git diff > changes-astyle.diff'
archiveArtifacts artifacts: 'changes-astyle.diff', fingerprint: true
sh '''
git diff --exit-code || \
{ echo "Please check indentation, see artifacts in the top right corner!"; exit 1; }
'''
}
post
{
failure
{
githubNotify context: 'Jenkins', description: 'indentation failed', status: 'PENDING'
}
}
}
stage('Build') {
options {
timeout(time: 30, unit: 'MINUTES')
}
steps {
sh '''
# running cmake...
mkdir build
cd build
cmake \
-G 'Ninja' \
-D CMAKE_CXX_FLAGS='-Werror' \
-D CMAKE_BUILD_TYPE='DebugRelease' \
-D ASPECT_ADDITIONAL_CXX_FLAGS='-O3' \
-D ASPECT_TEST_GENERATOR='Ninja' \
-D ASPECT_PRECOMPILE_HEADERS=ON \
-D ASPECT_UNITY_BUILD=ON \
-D ASPECT_WITH_NETCDF=ON \
-D ASPECT_RUN_ALL_TESTS='ON' \
-D ASPECT_INSTALL_EXAMPLES='ON' \
..
'''
sh '''
# compiling...
cd build
ninja
'''
}
post {
always
{
archiveArtifacts artifacts: 'build/detailed.log', fingerprint: true
}
failure
{
githubNotify context: 'Jenkins', description: 'build failed', status: 'FAILURE'
}
}
}
stage('Build Documentation') {
steps {
sh 'cd doc && ./update_parameters.sh ./build/aspect'
}
post {
failure
{
githubNotify context: 'Jenkins', description: 'documentation failed', status: 'FAILURE'
}
}
}
stage('cookbooks') {
options {
timeout(time: 20, unit: 'MINUTES')
}
steps {
sh '''
export BUILDDIR=`pwd`/build
export NP=`grep -c ^processor /proc/cpuinfo`
cd cookbooks && make -f check.mk CHECK=--validate BUILD=$BUILDDIR -j $NP
cd ..
cd benchmarks && make -f check.mk CHECK=--validate BUILD=$BUILDDIR -j $NP
'''
}
post {
failure
{
githubNotify context: 'Jenkins', description: 'cookbooks failed', status: 'FAILURE'
}
}
}
stage('Test') {
options {
timeout(time: 150, unit: 'MINUTES')
}
steps {
// Let ninja prebuild the test libraries and run
// the tests to create the output files in parallel. We
// want this to always succeed, because it does not generate
// useful output (we do this further down using 'ctest', however
// ctest can not run ninja in parallel, so this is the
// most efficient way to build the tests).
sh '''
# prebuilding tests...
cd build/tests
ninja -k 0 tests || true
'''
// Output the test results using ctest. Since
// the tests were prebuild in the previous shell
// command, this will be fast although it is not
// running in parallel. We use the ninja test generator, which
// does not support running ctest with -j.
sh '''
# generating test results...
cd build
ctest \
--no-compress-output \
--test-action Test \
--output-on-failure
'''
}
post {
always {
// Generate the 'Tests' output page in Jenkins
xunit testTimeMargin: '3000',
thresholdMode: 1,
thresholds: [failed(), skipped()],
tools: [CTest(pattern: 'build/Testing/**/*.xml')]
// Update the reference test output with the new test results
sh '''
# generating reference output...
cd build
ninja generate_reference_output
'''
// Generate the 'Artifacts' diff-file that can be
// used to update the test results
sh 'git diff tests > changes-test-results.diff'
archiveArtifacts artifacts: 'changes-test-results.diff'
githubNotify context: 'Jenkins', description: 'OK', status: 'SUCCESS'
}
failure
{
githubNotify context: 'Jenkins', description: 'tests failed', status: 'FAILURE'
}
}
}
}
}
}
}