Jenkinsfile 15.9 KB
Newer Older
1
#!/usr/bin/env groovy
2
@Library('jenkins-pipeline@1.0.9') _
3

4
5
6
7
8
9
10
11
12
pipeline {
  agent none
  options {
    ansiColor('xterm')
    timestamps()
  }
  stages {
    stage('Build') {
      parallel {
13
14
15
        // ************************ Docker-Conan *******************************
        stage('Docker-Conan') {
          agent {
16
            dockerfile {
Lars Bilke's avatar
Lars Bilke committed
17
              filename 'Dockerfile.gcc.full'
18
              dir 'scripts/docker'
19
              label 'docker'
20
21
              args '-v ccache:/home/jenkins/cache/ccache -v conan-cache:/home/jenkins/cache/conan'
              additionalBuildArgs '--pull'
22
23
            }
          }
Lars Bilke's avatar
Lars Bilke committed
24
25
26
27
          environment {
            CONTENTFUL_ACCESS_TOKEN = credentials('CONTENTFUL_ACCESS_TOKEN')
            CONTENTFUL_OGS_SPACE_ID = credentials('CONTENTFUL_OGS_SPACE_ID')
          }
28
29
          steps {
            script {
Lars Bilke's avatar
Lars Bilke committed
30
31
32
33
34
35
36
37
38
              // Install web dependencies
              sh("""
                cd web
                yarn --ignore-engines --non-interactive
                node node_modules/node-sass/scripts/install.js
                npm rebuild node-sass
                sudo -H pip install -r requirements.txt
                """.stripIndent())

39
40
41
42
43
44
45
46
47
              lock(resource: "conanCache-${env.NODE_NAME}") {
                sh 'find $CONAN_USER_HOME -name "system_reqs.txt" -exec rm {} \\;'
                configure {
                  cmakeOptions =
                    '-DOGS_USE_CONAN=ON ' +
                    '-DOGS_CONAN_BUILD=never ' +
                    '-DOGS_CPU_ARCHITECTURE=generic ' +
                    '-DOGS_PACKAGE_DEPENDENCIES=ON '
                }
48
49
50
51
              }
              build { }
              build { target="tests" }
              build { target="ctest" }
Lars Bilke's avatar
Lars Bilke committed
52
53
              build { target="web" }
              build { target="doc" }
54
55
56
              configure {
                cmakeOptions =
                  '-DOGS_BUILD_CLI=OFF ' +
Lars Bilke's avatar
Lars Bilke committed
57
                  '-DOGS_USE_PCH=OFF ' +     // see #1992
58
59
60
61
                  '-DOGS_BUILD_GUI=ON ' +
                  '-DOGS_BUILD_UTILS=ON ' +
                  '-DOGS_BUILD_TESTS=OFF ' +
                  '-DOGS_BUILD_METIS=ON '
62
                keepDir = true
63
64
65
66
67
68
69
70
71
72
73
74
              }
              build { }
            }
          }
          post {
            always {
              publishReports { }
            }
            failure {
                dir('build') { deleteDir() }
            }
            success {
Lars Bilke's avatar
Lars Bilke committed
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
              dir('web/public') { stash(name: 'web') }
              dir('build/docs') { stash(name: 'doxygen') }
              dir('scripts/jenkins') { stash(name: 'known_hosts', includes: 'known_hosts') }
              script {
                publishHTML(target: [allowMissing: false, alwaysLinkToLastBuild: true,
                  keepAll: true, reportDir: 'build/docs', reportFiles: 'index.html',
                  reportName: 'Doxygen'])
                publishHTML(target: [allowMissing: false, alwaysLinkToLastBuild: true,
                  keepAll: true, reportDir: 'web/public', reportFiles: 'index.html',
                  reportName: 'Web'])
                step([$class: 'WarningsPublisher', canResolveRelativePaths: false,
                  messagesPattern: """
                    .*DOT_GRAPH_MAX_NODES.
                    .*potential recursive class relation.*""",
                  parserConfigurations: [[parserName: 'Doxygen', pattern:
                  'build/DoxygenWarnings.log']], unstableTotalAll: '0'])
91
92
                archiveArtifacts 'build/*.tar.gz,build/conaninfo.txt'
                dir('build') { deleteDir() }
Lars Bilke's avatar
Lars Bilke committed
93
              }
94
95
            }
          }
96
        }
Lars Bilke's avatar
Lars Bilke committed
97
        // ********************* Docker-Conan-Debug ****************************
98
99
        stage('Docker-Conan-Debug') {
          agent {
100
101
102
            dockerfile {
              filename 'Dockerfile.gcc.minimal'
              dir 'scripts/docker'
103
              label 'docker'
104
              args '-v ccache:/home/jenkins/cache/ccache -v conan-cache:/home/jenkins/cache/conan'
105
              additionalBuildArgs '--pull'
106
107
108
109
            }
          }
          steps {
            script {
110
111
112
113
114
115
116
117
118
              lock(resource: "conanCache-${env.NODE_NAME}") {
                sh 'find $CONAN_USER_HOME -name "system_reqs.txt" -exec rm {} \\;'
                configure {
                  cmakeOptions =
                    '-DOGS_USE_CONAN=ON ' +
                    '-DOGS_CONAN_BUILD=never ' +
                    '-DOGS_CPU_ARCHITECTURE=generic '
                  config = 'Debug'
                }
119
120
121
122
123
124
125
126
127
128
129
130
              }
              build { }
              build { target = 'tests' }
            }
          }
          post {
            always {
              publishReports { }
              dir('build') { deleteDir() }
            }
          }
        }
131
        // ************************** envinf1 **********************************
Lars Bilke's avatar
Lars Bilke committed
132
133
134
135
136
137
138
139
        stage('Envinf1 (serial)') {
          agent { label "envinf1"}
          steps {
            script {
              configure {
                cmakeOptions =
                  '-DOGS_BUILD_UTILS=ON ' +
                  '-DOGS_BUILD_METIS=ON ' +
Lars Bilke's avatar
Lars Bilke committed
140
                  '-DBUILD_SHARED_LIBS=ON '
Lars Bilke's avatar
Lars Bilke committed
141
142
                env = 'envinf1/cli.sh'
              }
143
144
145
146
              build {
                env = 'envinf1/cli.sh'
                cmd_args = '-l 30'
              }
Lars Bilke's avatar
Lars Bilke committed
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
              build {
                env = 'envinf1/cli.sh'
                target = 'tests'
              }
              build {
                env = 'envinf1/cli.sh'
                target = 'ctest'
              }
            }
          }
          post {
            always {
              publishReports { }
              dir('build') { deleteDir() }
            }
          }
        }
164
165
166
167
168
169
170
171
172
173
174
175
        stage('Envinf1 (parallel)') {
          agent { label "envinf1"}
          steps {
            script {
              configure {
                cmakeOptions =
                  '-DOGS_BUILD_UTILS=ON ' +
                  '-DOGS_BUILD_METIS=ON ' +
                  '-DBUILD_SHARED_LIBS=ON ' +
                  '-DOGS_USE_PETSC=ON '
                env = 'envinf1/petsc.sh'
              }
176
177
178
179
              build {
                env = 'envinf1/petsc.sh'
                cmd_args = '-l 30'
              }
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
              build {
                env = 'envinf1/petsc.sh'
                target = 'tests'
              }
              build {
                env = 'envinf1/petsc.sh'
                target = 'ctest'
              }
            }
          }
          post {
            always {
              publishReports { }
              dir('build') { deleteDir() }
            }
          }
        }
197
        // ************************** Windows **********************************
198
        stage('Win') {
Lars Bilke's avatar
Lars Bilke committed
199
          agent {label 'win && conan' }
200
201
          environment {
            MSVC_NUMBER = '15'
Lars Bilke's avatar
Lars Bilke committed
202
            MSVC_VERSION = '2017'
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
          }
          steps {
            script {
              // CLI
              configure {
                cmakeOptions =
                  '-DOGS_USE_CONAN=ON ' +
                  '-DOGS_DOWNLOAD_ADDITIONAL_CONTENT=ON '
              }
              build { }
              build { target="tests" }
              build { target="ctest" }
              // GUI
              configure {
                cmakeOptions =
                  '-DOGS_BUILD_GUI=ON ' +
                  '-DOGS_BUILD_UTILS=ON ' +
                  '-DOGS_BUILD_TESTS=OFF ' +
                  '-DOGS_BUILD_SWMM=ON ' +
222
223
                  '-DOGS_BUILD_METIS=ON ' +
                  '-DOGS_PACKAGE_DEPENDENCIES=ON '
224
225
226
227
228
229
230
231
                  keepDir = true
              }
              build { }
            }
          }
          post {
            always {
              publishReports { }
Lars Bilke's avatar
Lars Bilke committed
232
              warnings(canResolveRelativePaths: false,
233
                  consoleParsers: [[parserName: 'MSBuild']],
234
235
                  excludePattern: '.*\\.conan.*',
                  messagesPattern: '.*QVTK.*')
Lars Bilke's avatar
Lars Bilke committed
236
            }
237
238
239
240
241
242
243
244
            failure {
                dir('build') { deleteDir() }
            }
            success {
                archiveArtifacts 'build/*.zip,build/conaninfo.txt'
                dir('build') { deleteDir() }
            }
          }
Lars Bilke's avatar
Lars Bilke committed
245
        }
Lars Bilke's avatar
Lars Bilke committed
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
        // ****************************** Mac **********************************
        stage('Mac') {
          agent { label "mac"}
          steps {
            script {
              configure {
                cmakeOptions =
                  '-DOGS_USE_CONAN=ON ' +
                  '-DOGS_CONAN_BUILD=never ' +
                  '-DOGS_CPU_ARCHITECTURE=core2 ' +
                  '-DOGS_DOWNLOAD_ADDITIONAL_CONTENT=ON ' +
                  '-DOGS_BUILD_GUI=ON ' +
                  '-DOGS_BUILD_UTILS=ON ' +
                  '-DOGS_BUILD_METIS=ON ' +
                  '-DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" '
              }
              build {
                target = 'tests'
                cmd_args = '-j $(( `sysctl -n hw.ncpu` - 2 ))'
              }
              build {
                target = 'ctest'
                cmd_args = '-j $(( `sysctl -n hw.ncpu` - 2 ))'
              }
              build {
                target = 'package'
                cmd_args = '-j $(( `sysctl -n hw.ncpu` - 2 ))'
              }
            }
          }
          post {
            always {
              publishReports { }
            }
            failure {
                dir('build') { deleteDir() }
            }
            success {
                archiveArtifacts 'build/*.tar.gz,build/*.dmg,build/conaninfo.txt'
                dir('build') { deleteDir() }
            }
          }
        }
289
290
      } // end parallel
    } // end stage Build
291
292
    // *************************** Log Parser **********************************
    stage('Log Parser') {
293
      agent any
294
295
296
297
298
299
300
301
302
303
304
305
306
      steps {
        script {
          checkout scm
          step([$class: 'LogParserPublisher',
              failBuildOnError: true,
              projectRulePath: "scripts/jenkins/all-log-parser.rules",
              showGraphs: true,
              unstableOnWarning: false,
              useProjectRule: true
          ])
        }
      }
    }
307
    stage('Master') {
Lars Bilke's avatar
Lars Bilke committed
308
      when { environment name: 'JOB_NAME', value: 'ufz/ogs/master' }
309
310
      parallel {
        // ************************* Deploy Web ********************************
Lars Bilke's avatar
Lars Bilke committed
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
        stage('Deploy Web') {
          agent any
          steps {
            dir('web') { unstash 'web' }
            dir('doxygen') { unstash 'doxygen' }
            unstash 'known_hosts'
            script {
              sshagent(credentials: ['www-data_jenkins']) {
                sh 'rsync -a --delete --stats -e "ssh -o UserKnownHostsFile=' +
                   'known_hosts" web/. ' +
                   'www-data@jenkins.opengeosys.org:/var/www/dev.opengeosys.org'
                sh 'rsync -a --delete --stats -e "ssh -o UserKnownHostsFile=' +
                   'known_hosts" doxygen/. ' +
                   'www-data@jenkins.opengeosys.org:/var/www/doxygen.opengeosys.org'
              }
            }
          }
        }
329
330
331
332
333
334
335
336
337
338
        // *********************** Deploy envinf1 ******************************
        stage('Deploy envinf1') {
          agent { label "envinf1"}
          steps {
            script {
              configure {
                cmakeOptions =
                  '-DOGS_BUILD_UTILS=ON ' +
                  '-DOGS_BUILD_METIS=ON ' +
                  '-DBUILD_SHARED_LIBS=ON ' +
Lars Bilke's avatar
Lars Bilke committed
339
340
                  '-DCMAKE_INSTALL_PREFIX=/global/apps/ogs/head/standard ' +
                  '-DOGS_MODULEFILE=/global/apps/modulefiles/ogs/head/standard ' +
341
342
343
344
345
346
                  '-DOGS_CPU_ARCHITECTURE=core-avx-i '
                env = 'envinf1/cli.sh'
              }
              build {
                env = 'envinf1/cli.sh'
                target = 'install'
347
                cmd_args = '-l 30'
348
349
              }
            }
350
          }
351
352
353
          post {
            always {
              dir('build') { deleteDir() }
354
355
            }
          }
356
357
358
359
360
361
362
363
364
365
366
367
        }
        // ******************** Deploy envinf1 PETSc ***************************
        stage('Deploy envinf1 PETSc') {
          agent { label "envinf1"}
          steps {
            script {
              configure {
                cmakeOptions =
                  '-DOGS_USE_PETSC=ON ' +
                  '-DOGS_BUILD_UTILS=ON ' +
                  '-DOGS_BUILD_METIS=ON ' +
                  '-DBUILD_SHARED_LIBS=ON ' +
Lars Bilke's avatar
Lars Bilke committed
368
369
                  '-DCMAKE_INSTALL_PREFIX=/global/apps/ogs/head/petsc ' +
                  '-DOGS_MODULEFILE=/global/apps/modulefiles/ogs/head/petsc ' +
370
371
372
373
374
375
                  '-DOGS_CPU_ARCHITECTURE=core-avx-i '
                env = 'envinf1/petsc.sh'
              }
              build {
                env = 'envinf1/petsc.sh'
                target = 'install'
376
                cmd_args = '-l 30'
377
378
379
380
381
382
              }
            }
          }
          post {
            always {
              dir('build') { deleteDir() }
383
384
385
            }
          }
        }
386
387
388
        // ************************** Sanitizer ********************************
        stage('Sanitizer') {
          agent {
389
390
391
            dockerfile {
              filename 'Dockerfile.clang.minimal'
              dir 'scripts/docker'
392
              label 'docker'
393
394
              args '-v ccache:/home/jenkins/cache/ccache -v conan-cache:/home/jenkins/cache/conan'
              additionalBuildArgs '--pull'
395
396
397
398
            }
          }
          steps {
            script {
399
              sh 'find $CONAN_USER_HOME -name "system_reqs.txt" -exec rm {} \\;'
400
401
              configure {
                cmakeOptions =
402
                  '-DOGS_USE_CONAN=ON ' +
403
404
405
406
407
                  '-DOGS_ADDRESS_SANITIZER=ON ' +
                  '-DOGS_UNDEFINED_BEHAVIOR_SANITIZER=ON ' +
                  '-DOGS_BUILD_UTILS=ON '
              }
              try {
408
                build { cmd = 'UBSAN_OPTIONS=print_stacktrace=1 ninja test' }
409
410
411
412
              }
              catch(err) { echo "Clang sanitizer for unit tests failed!" }

              try {
413
                build { cmd = 'UBSAN_OPTIONS=print_stacktrace=1 ninja ctest' }
414
415
416
417
418
419
420
              }
              catch(err) { echo "Clang sanitizer for end-to-end tests failed!" }
            }
          }
          post {
            always {
              dir('build') { deleteDir() }
Lars Bilke's avatar
Lars Bilke committed
421
422
              warnings(canResolveRelativePaths: false,
                  consoleParsers: [[parserName: 'Clang (LLVM based)']])
423
424
            }
          }
425
        }
426
427
428
429
430
431
432
433
434
435
436
437
438
        // ********************* Update ufz/ogs-data ***************************
        stage('Update ogs-data') {
          agent any
          steps {
            script {
              dir('ogs') { checkout scm }
              dir('ogs-data') {
                checkout(changelog: false, poll: false, scm: [$class: 'GitSCM',
                  extensions: [[$class: 'CloneOption', shallow: true]],
                  userRemoteConfigs: [[
                    credentialsId: '2719b702-1298-4e87-8464-5dfc62fbd923',
                    url: 'https://github.com/ufz/ogs-data']]])
                sh 'rsync -av --delete --exclude .git/ ../ogs/Tests/Data/ .'
439
                sh "git add --all . && git diff --quiet && git diff --staged --quiet || git commit -am 'Update'"
440
441
442
443
444
445
446
447
448
                withCredentials([usernamePassword(
                  credentialsId: '2719b702-1298-4e87-8464-5dfc62fbd923',
                  passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
                  sh 'git push https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/ufz/ogs-data HEAD:master'
                }
              }
            }
          }
        }
449
450
451
452
453
454
455
456
457
458
459
460
461
462
        // *************************** Post ************************************
        stage('Post') {
          agent any
          steps {
            script {
              def helper = new ogs.helper()
              checkout scm
              def tag = helper.getTag()
              if (tag != "") {
                keepBuild()
                currentBuild.displayName = tag
                helper.notification(msg: "Marked build for ${tag}.", script: this)
              }
            }
463
464
          }
        }
465
      } // end parallel
466
467
468
469
470
      post {
        always {
          step([$class: 'AnalysisPublisher', unstableNewAll: '1'])
        }
      }
471
    } // end stage master
472
  }
Lars Bilke's avatar
Lars Bilke committed
473
}