-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
76 lines (67 loc) · 2.82 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
#!groovy
node {
def exception = null;
try {
stage('Checkout') {
// get source code
checkout scm
}
stage('Build') {
gradle = load 'jenkins/gradle.groovy'
// check that the whole project compiles
// gradle 'clean build'
gradle.cleanAndCompile()
}
stage('Test') {
gradle.test()
step([$class: 'JUnitResultArchiver', testResults:
'**/build/test-results/TEST-*.xml'])
}
stage('Code Quality') {
parallel(
'pmd': {
// static code analysis
gradle.codeQualityPmd()
step([$class: 'PmdPublisher', pattern: 'build/reports/pmd/*.xml'])
},
'checkstyle': {
gradle.codeQualityCheckstyle()
step([$class: 'CheckStylePublisher', pattern: 'build/reports/checkstyle/*.xml'])
},
'findbugs': {
gradle.codeQualityCheckstyle()
step([$class: 'FindBugsPublisher', pattern: 'build/reports/findbugs/*.xml'])
},
'jacoco': {
// Jacoco report rendering
gradle.aggregateJaCoCoReports()
//publish(target: [reportDir:'build/reports/jacoco/jacocoTestReport/html',reportFile: 'index.html', reportName: 'Code Coverage'])
//step([$class: 'JaCoCoPublisher', execPattern: 'build/jacoco/*.exec', classPattern: 'build/classes/main', sourcePattern: 'src/main/java'])
}
)
}
// TODO this is a temporary fix until the Sonarqube plugin has been adapted to pipelines: https://github.com/jenkinsci/pipeline-plugin/blob/master/COMPATIBILITY.md
// Requires the Credentials Binding plugin
stage('Publish Metrics to Sonarqube') {
// requires SonarQube Scanner 2.8+
def scannerHome = tool 'SonarQubeScanner2.8';
withSonarQubeEnv('Local SonarQube') {
sh "${scannerHome}/bin/sonar-scanner"
}
}
} catch (e) {
exception = e;
}
stage('Send notification') {
if (exception != null) {
echo "Caught Exception ${exception}"
String recipient = '[email protected]'
mail subject: "${env.JOB_NAME} (${env.BUILD_NUMBER}) failed",
body: "It appears that ${env.BUILD_URL} is failing, you should do something about that!\n\n" + exception,
to: recipient,
replyTo: recipient,
from: '[email protected]'
error "Failing build because of ${exception}"
}
}
}