-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
143 lines (124 loc) · 4.21 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
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
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'
sh './grailsw -v' // Output grails version for verification checks
}
}
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('Unit Test') {
steps {
sh "./gradlew --build-cache test"
}
post {
always {
junit allowEmptyResults: true, testResults: 'build/test-results/test/*.xml'
}
}
}
stage('Integration Test') {
steps {
sh "./gradlew --build-cache integrationTest"
}
post {
always {
junit allowEmptyResults: true, testResults: 'build/test-results/integrationTest/*.xml'
}
}
}
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 {
publishHTML([
allowMissing : false,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : 'build/reports/tests',
reportFiles : 'index.html',
reportName : 'Test Report',
reportTitles : 'Test'
])
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')
publishCoverage adapters: [jacocoAdapter('**/reports/jacoco/jacocoTestReport.xml')]
outputTestResults()
jacoco classPattern: '**/build/classes', execPattern: '**/build/jacoco/*.exec', sourceInclusionPattern: '**/*.java,**/*.groovy', sourcePattern: '**/src/main/groovy,**/grails-app/controllers,**/grails-app/domain,**/grails-app/services,**/grails-app/utils'
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*.log'
zulipNotification(topic: 'mdm-plugin-awsglue')
}
}
}