-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
103 lines (90 loc) · 2.7 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
pipeline {
agent any
environment {
JENKINS = 'true'
}
tools {
jdk 'jdk-17'
}
options {
timestamps()
timeout(time: 30, unit: 'MINUTES')
skipStagesAfterUnstable()
buildDiscarder(logRotator(numToKeepStr: '30'))
}
stages {
stage('Clean') {
// Only clean when the last build failed
when {
expression {
currentBuild.previousBuild?.currentResult == 'FAILURE'
}
}
steps {
sh "./gradlew clean"
}
}
stage('Info') {
steps {
sh './gradlew -v' // Output gradle version for verification checks
sh './gradlew jvmArgs sysProps'
}
}
stage('Test cleanup & Compile') {
steps {
sh "./gradlew jenkinsClean"
sh './gradlew compile'
}
}
stage('License Header Check') {
steps {
warnError('Missing License Headers') {
sh './gradlew --build-cache license'
}
}
}
stage('Static Code Analysis') {
steps {
sh "./gradlew -PciRun=true staticCodeAnalysis jacocoTestReport"
}
}
// stage('Sonarqube') {
// when {
// branch 'develop'
// }
// steps {
// withSonarQubeEnv('JenkinsQube') {
// sh "./gradlew sonarqube"
// }
// }
// }
stage('Deploy to Artifactory') {
when {
allOf {
anyOf {
branch 'main'
branch 'develop'
}
expression {
currentBuild.currentResult == 'SUCCESS'
}
}
}
steps {
script {
sh "./gradlew publish"
}
}
}
}
post {
always {
recordIssues enabledForFailure: true, tools: [java(), javaDoc()]
recordIssues enabledForFailure: true, tool: checkStyle(pattern: '**/reports/checkstyle/*.xml')
recordIssues enabledForFailure: true, tool: codeNarc(pattern: '**/reports/codenarc/*.xml')
recordIssues enabledForFailure: true, tool: spotBugs(pattern: '**/reports/spotbugs/*.xml', useRankAsPriority: true)
recordIssues enabledForFailure: true, tool: pmdParser(pattern: '**/reports/pmd/*.xml')
zulipNotification(topic: 'mdm-plugin-testing-utils')
}
}
}