forked from slam-it/sonar-quality-gates-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
89 lines (74 loc) · 2.45 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
pipeline {
agent any
tools {
maven 'Maven'
jdk 'Java11'
}
stages {
stage('Build') {
steps {
sh "mvn clean install site"
sh "rm -rf target/site/jacoco-aggregate"
sh "rm -rf target/site/jacoco-ut"
sh "rm -rf target/site/jacoco-it"
}
post {
always {
junit 'target/surefire-reports/*.xml'
jacoco(
execPattern: 'target/*.exec',
classPattern: 'target/classes',
sourcePattern: 'src/main/java',
exclusionPattern: 'src/test*'
)
}
}
}
stage('Record Coverage') {
when { branch 'master' }
steps {
script {
currentBuild.result = 'SUCCESS'
}
step([$class: 'MasterCoverageAction', scmVars: [GIT_URL: env.GIT_URL]])
}
}
stage('PR Coverage to Github') {
when { allOf {not { branch 'master' }; expression { return env.CHANGE_ID != null }} }
steps {
script {
currentBuild.result = 'SUCCESS'
}
step([$class: 'CompareCoverageAction', publishResultAs: 'statusCheck', scmVars: [GIT_URL: env.GIT_URL]])
}
}
stage('Vulnerability Check') {
tools {
jdk 'Java8'
}
steps {
sh "mvn org.owasp:dependency-check-maven:5.2.2:check -Dformat=ALL"
}
}
stage('Dependency Update Check') {
steps {
sh "mvn org.codehaus.mojo:versions-maven-plugin:2.7:dependency-updates-report -DdependencyUpdatesReportFormats=html,xml"
}
}
stage('Publish results to Sonarqube') {
steps {
sh "mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar -Dsonar.host.url=http://192.168.1.15:9000/sonar/ -Dsonar.sources=. -Dsonar.dependencyCheck.reportPath=target/dependency-check-report.xml -Dsonar.dependencyCheck.htmlReportPath=target/dependency-check-report.html"
}
}
stage('Quality Gate') {
steps {
sh "mvn com.hack23.maven:sonar-quality-gates-maven-plugin:1.0.0:inspect -Dsonar.host.url=http://192.168.1.15:9000/sonar"
}
}
stage('Results') {
steps {
archive 'target/*.jar'
}
}
}
}