Skip to content

Commit ebcc448

Browse files
committed
Add Jenkinsfile
1 parent 8f348c9 commit ebcc448

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

Jenkinsfile

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
pipeline {
2+
agent any
3+
4+
environment {
5+
JDK_TOOL_NAME = 'JDK 11'
6+
MAVEN_TOOL_NAME = 'Maven 3.8.6'
7+
}
8+
9+
options {
10+
skipStagesAfterUnstable()
11+
disableConcurrentBuilds abortPrevious: true
12+
}
13+
14+
stages {
15+
stage('Clean') {
16+
steps {
17+
withMaven(jdk: env.JDK_TOOL_NAME, maven: env.MAVEN_TOOL_NAME) {
18+
sh 'mvn clean'
19+
}
20+
}
21+
}
22+
stage('Format Check') {
23+
options {
24+
timeout(activity: true, time: 60, unit: 'SECONDS')
25+
}
26+
steps {
27+
withMaven(jdk: env.JDK_TOOL_NAME, maven: env.MAVEN_TOOL_NAME) {
28+
sh 'mvn spotless:check'
29+
}
30+
}
31+
}
32+
stage('Build') {
33+
options {
34+
timeout(activity: true, time: 120, unit: 'SECONDS')
35+
}
36+
steps {
37+
withMaven(jdk: env.JDK_TOOL_NAME, maven: env.MAVEN_TOOL_NAME) {
38+
sh 'mvn -DskipTests=true package'
39+
}
40+
}
41+
42+
post {
43+
success {
44+
archiveArtifacts artifacts: '**/target/*.jar'
45+
}
46+
}
47+
}
48+
stage('Code Analysis') {
49+
when {
50+
anyOf {
51+
branch 'master'
52+
tag 'v*'
53+
changeRequest()
54+
}
55+
}
56+
options {
57+
timeout(activity: true, time: 120, unit: 'SECONDS')
58+
}
59+
steps {
60+
withMaven(jdk: env.JDK_TOOL_NAME, maven: env.MAVEN_TOOL_NAME) {
61+
sh 'mvn pmd:pmd pmd:cpd spotbugs:spotbugs'
62+
}
63+
}
64+
post {
65+
always {
66+
recordIssues enabledForFailure: true, tools: [spotBugs(), cpd(pattern: '**/target/cpd.xml'), pmdParser(pattern: '**/target/pmd.xml')]
67+
}
68+
}
69+
}
70+
stage('Unit Tests') {
71+
when {
72+
anyOf {
73+
branch 'master'
74+
tag 'v*'
75+
changeRequest()
76+
}
77+
}
78+
options {
79+
timeout(activity: true, time: 120, unit: 'SECONDS')
80+
}
81+
steps {
82+
withMaven(jdk: env.JDK_TOOL_NAME, maven: env.MAVEN_TOOL_NAME) {
83+
sh 'mvn -P coverage -Dskip.failsafe.tests=true test'
84+
}
85+
}
86+
post {
87+
always {
88+
junit testResults: '**/target/surefire-reports/TEST-*.xml', allowEmptyResults: true
89+
}
90+
}
91+
}
92+
stage('Integration Tests') {
93+
when {
94+
anyOf {
95+
branch 'master'
96+
tag 'v*'
97+
changeRequest()
98+
}
99+
}
100+
options {
101+
timeout(activity: true, time: 120, unit: 'SECONDS')
102+
}
103+
steps {
104+
withMaven(jdk: env.JDK_TOOL_NAME, maven: env.MAVEN_TOOL_NAME) {
105+
sh 'mvn -P coverage -Dskip.surefire.tests=true verify'
106+
}
107+
}
108+
post {
109+
always {
110+
junit testResults: '**/target/failsafe-reports/TEST-*.xml', allowEmptyResults: true
111+
}
112+
success {
113+
publishCoverage adapters: [jacoco(mergeToOneReport: true, path: '**/target/site/jacoco/jacoco.xml')]
114+
}
115+
}
116+
}
117+
stage('Deploy Jar to Internal Nexus Repository') {
118+
when {
119+
anyOf {
120+
branch 'master'
121+
tag 'v*'
122+
}
123+
}
124+
steps {
125+
withMaven(jdk: env.JDK_TOOL_NAME, maven: env.MAVEN_TOOL_NAME) {
126+
// Tests were already executed separately, so disable tests within this step
127+
sh 'mvn -DskipTests=true deploy'
128+
}
129+
}
130+
}
131+
}
132+
post {
133+
always {
134+
recordIssues enabledForFailure: true, tools: [mavenConsole(), java(), javaDoc()]
135+
}
136+
}
137+
}

0 commit comments

Comments
 (0)