-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjenkins.lib
More file actions
154 lines (136 loc) · 4.28 KB
/
jenkins.lib
File metadata and controls
154 lines (136 loc) · 4.28 KB
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
#!groovy
// separated with whitespace
emailAddresses = ""
def printStackTrace(exception) {
// TODO in order to use the following classes some admin configuration within jenkins
// is necessary - it's not working out of the box
//def sw = new StringWriter()
//def pw = new PrintWriter(sw)
//exception.printStackTrace(pw)
//echo sw.toString()
echo exception.toString()
}
def setToFailure() {
currentBuild.result = 'FAILURE'
}
// Sets the current build status to UNSTABLE
// (if the status is already FAILURE then it remains FAILURE - we don't set UNSTABLE to FAILURE)
def setToUnstable() {
if (currentBuild.result != 'FAILURE') {
currentBuild.result = 'UNSTABLE'
}
}
def printBuildResult() {
echo "[CURRENT BUILD] currentBuild.currentResult=${currentBuild.currentResult}"
}
def publishToDos() {
openTasks canComputeNew: false,
defaultEncoding: '',
excludePattern: '',
healthy: '',
high: 'FIXME, XXX',
low: '',
normal: 'TODO, REVIEW',
pattern: '**/src/**/*.java',
unHealthy: ''
printBuildResult()
}
// ignores missing files
def publishCheckstyle() {
checkstyle canComputeNew: false,
defaultEncoding: '',
healthy: '',
pattern: '**/target/checkstyle-result.xml',
unHealthy: ''
printBuildResult()
}
// ignores missing files
def publishSpotbugs() {
findbugs canComputeNew: false,
defaultEncoding: '',
excludePattern: '',
healthy: '',
includePattern: '',
pattern: '**/target/spotbugsXml.xml',
unHealthy: ''
printBuildResult()
}
// ignores missing files
def publishOwaspDependencyCheckResults() {
step([$class: 'DependencyCheckPublisher',
pattern: 'target/site/dependency-check-report.xml'
])
printBuildResult()
}
// ignores missing files
def publishHtmlReports(reportDir = 'target/staging/') {
publishHTML([allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: reportDir,
reportFiles: 'index.html',
reportName: 'Maven Site',
reportTitles: ''])
printBuildResult()
}
// ignores missing files
def publishXunitReports() {
step([$class: 'XUnitPublisher',
testTimeMargin: '3000',
thresholdMode: 1,
thresholds: [
[$class: 'FailedThreshold',
failureNewThreshold: '1000',
failureThreshold: '1000',
unstableNewThreshold: '0',
unstableThreshold: '0'
],
[$class: 'SkippedThreshold',
failureNewThreshold: '500',
failureThreshold: '500',
unstableNewThreshold: '1000',
unstableThreshold: '1000'
]
],
tools: [
[$class: 'JUnitType',
deleteOutputFiles: true,
failIfNotNew: false,
pattern: '**/target/surefire-reports/**/*.xml, **/target/failsafe-reports/*.xml, **/target/karma-reports/*.xml ',
skipNoTestFiles: true,
stopProcessingIfError: false
]
]
])
printBuildResult()
}
// ignores missing files
def publishJaCoCoTestCoverage() {
jacoco classPattern: '**/target/classes',
exclusionPattern: '**/*Test*.class, **/*IT.class, **/*Dto.class, **/*Command.class, **/*Exception.class',
execPattern: '**/target/jacoco-reports/jacoco.exec',
maximumBranchCoverage: '40',
maximumClassCoverage: '60',
maximumComplexityCoverage: '40',
maximumInstructionCoverage: '40',
maximumLineCoverage: '40',
maximumMethodCoverage: '40',
sourcePattern: '**/src/main/java'
printBuildResult()
}
def notifyViaMail() {
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: emailAddresses,
sendToIndividuals: true
])
printBuildResult()
}
def setJobProperties() {
properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '',
artifactNumToKeepStr: '',
daysToKeepStr: '',
numToKeepStr: '75')),
disableConcurrentBuilds()])
}
return this