This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile
104 lines (89 loc) · 3.17 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
#!/usr/bin/env groovy
// Import pipeline library for utility methods & classes:
// ansicolor(), Notifier, PullRequests, Strings
@Field
public static final String PROJ_URL = 'https://github.com/zanata/openprops'
@Field
public static final String PIPELINE_LIBRARY_BRANCH = 'v0.3.0'
@Library('github.com/zanata/zanata-pipeline-library@v0.3.0')
import org.zanata.jenkins.Notifier
import org.zanata.jenkins.PullRequests
import org.zanata.jenkins.ScmGit
import static org.zanata.jenkins.Reporting.codecov
import static org.zanata.jenkins.StackTraces.getStackTrace
import groovy.transform.Field
PullRequests.ensureJobDescription(env, manager, steps)
@Field
def pipelineLibraryScmGit
@Field
def mainScmGit
@Field
def notify
// initialiser must be run separately (bindings not available during compilation phase)
/* Only keep the 10 most recent builds. */
def projectProperties = [
[
$class: 'GithubProjectProperty',
projectUrlStr: PROJ_URL
],
[
$class: 'BuildDiscarderProperty',
strategy: [$class: 'LogRotator', numToKeepStr: '10']
],
]
properties(projectProperties)
def surefireTestReports='target/surefire-reports/TEST-*.xml'
timestamps {
node {
echo "running on node ${env.NODE_NAME}"
pipelineLibraryScmGit = new ScmGit(env, steps, 'https://github.com/zanata/zanata-pipeline-library')
pipelineLibraryScmGit.init(PIPELINE_LIBRARY_BRANCH)
mainScmGit = new ScmGit(env, steps, PROJ_URL)
mainScmGit.init(env.BRANCH_NAME)
notify = new Notifier(env, steps, currentBuild,
pipelineLibraryScmGit, mainScmGit, (env.GITHUB_COMMIT_CONTEXT) ?: 'Jenkinsfile',
)
ansicolor {
// ensure the build can handle at-signs in paths:
dir("@") {
try {
stage('Checkout') {
notify.started()
checkout scm
}
stage('Check build tools') {
// Note: if next stage happens on another node, mvnw might have to download again
sh "./mvnw --version"
}
stage('Build') {
notify.startBuilding()
sh """./mvnw -e clean verify \
--batch-mode \
--settings .travis-settings.xml \
--update-snapshots \
-Dmaven.test.failure.ignore \
-DstaticAnalysis \
"""
// step([$class: 'CheckStylePublisher', pattern: '**/target/checkstyle-result.xml', unstableTotalAll:'0'])
// step([$class: 'PmdPublisher', pattern: '**/target/pmd.xml', unstableTotalAll:'0'])
// step([$class: 'FindBugsPublisher', pattern: '**/findbugsXml.xml', unstableTotalAll:'0'])
junit testResults: "**/${surefireTestReports}"
// send test coverage data to codecov.io
codecov(env, steps, mainScmGit)
// skip coverage report if unstable
if (currentBuild.result == null) {
step([ $class: 'JacocoPublisher' ])
}
notify.testResults('UNIT', currentBuild.result)
}
} catch (e) {
currentBuild.result='FAILURE'
notify.failed()
throw e
}
}
}
notify.finish()
currentBuild.result = (currentBuild.result) ?: 'SUCCESS'
}
}