Debian Codegraph @

.jenkins/style-checks/Jenkinsfile

raw
1 // The style checker build will check the style of all the code in the
2 // repository.
3 pipeline
4 {
5 // Run inside of the custom Docker image for style checking.
6 agent
7 {
8 docker
9 {
10 image 'mlpack/jenkins-mlpack-style-checks:latest'
11 alwaysPull true
12 }
13 }
14
15 options
16 {
17 // Only allow one build at a time of this job.
18 disableConcurrentBuilds(abortPrevious: true)
19
20 // We will do checkout manually.
21 skipDefaultCheckout()
22 }
23
24 stages
25 {
26 // Clean the workspace and check out the code.
27 stage('Set up workspace')
28 {
29 steps
30 {
31 cleanWs(deleteDirs: true,
32 disableDeferredWipeout: true,
33 notFailBuild: true)
34 checkout scm
35
36 script
37 {
38 // Set the initial status.
39 u = load '.jenkins/utils.groovy'
40 u.startCheck('Style checks', 'Setting up workspace...')
41 }
42
43 sh '''
44 git clone https://github.com/mlpack/jenkins-conf
45 '''
46 }
47 }
48
49 // Now we can run those scripts.
50 stage('Check code style')
51 {
52 steps
53 {
54 script { u.updateCheckStatus('Checking code style...') }
55
56 sh '''
57 mkdir -p reports
58 ./jenkins-conf/linter/lint.sh \
59 --root . \
60 --reports reports/cpplint.junit.xml \
61 --dir ./src/mlpack
62
63 # Print the results.
64 cat reports/cpplint.junit.xml
65 '''
66 }
67 }
68 }
69
70 post
71 {
72 // Mark unstable builds as failed.
73 unstable { script { u.finishCheck('Style checks failed.', false) } }
74 failure { script { u.finishCheck('Style checks failed.', false) } }
75 success { script { u.finishCheck('Style checks passed.', true) } }
76
77 always
78 {
79 // Process the test results.
80 junit(allowEmptyResults: true,
81 skipPublishingChecks: true,
82 testResults: '**/reports/cpplint.junit.xml')
83
84 // Clean the workspace after the build too.
85 cleanWs(cleanWhenNotBuilt: true,
86 deleteDirs: true,
87 disableDeferredWipeout: true,
88 notFailBuild: true)
89 }
90 }
91 }