-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jenkinsfile
128 lines (128 loc) · 4.67 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
pipeline {
agent any
environment {
GRADLE_OPTS = '-Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dorg.gradle.warning.mode=all'
// JAVA_OPTS = ''
}
options {
ansiColor('xterm')
}
tools {
// git 'Git'
gradle 'Gradle 4.9'
jdk 'oraclejdk8'
}
stages {
stage('prebuild') {
steps {
sh 'rm -rf build/libs'
sh 'chmod +x gradlew'
sh 'java -version'
sh 'gradle -version'
sh './gradlew -version'
sh 'export'
}
}
stage('CIWorkspace') {
steps {
withGradle {
sh './gradlew clean setupCiWorkspace -S'
}
}
}
stage('build') {
steps {
withGradle {
sh './gradlew clean build -S'
}
}
}
stage('test') {
steps {
withGradle {
sh './gradlew test -S'
}
}
}
stage('publish') {
steps {
withCredentials([file(credentialsId: 'secret.json', variable: 'SECRET_FILE')]) {
withGradle {
sh './gradlew publish -S'
}
}
}
}
stage('CurseForge') {
steps {
withCredentials([file(credentialsId: 'secret.json', variable: 'SECRET_FILE')]) {
withGradle {
sh './gradlew -x publish curseforge -S'
}
}
}
}
stage('SonarQube') {
tools {
jdk "oraclejdk11"
}
environment {
scannerHome = tool 'SonarQube'
}
steps {
// withCredentials([file(credentialsId: 'secret.json', variable: 'SECRET_FILE')]) {
// withGradle {
// sh './gradlew sonarqube -S'
// }
// }
withSonarQubeEnv(installationName: 'SonarCloud', , envOnly: false) {
sh "${scannerHome}/bin/sonar-scanner -Dsonar.java.jdkHome=${JAVA_HOME}"
}
}
}
stage('postbuild') {
steps {
archiveArtifacts artifacts: 'build/libs/*.jar', followSymlinks: false
javadoc javadocDir: 'build/docs/javadoc', keepAll: false
fingerprint 'build/libs/*.zip'
junit allowEmptyResults: true, testResults: '**/build/test-results/junit-platform/*.xml'
jacoco classPattern: '**/build/classes/java', execPattern: '**/build/jacoco/**.exec', sourceInclusionPattern: '**/*.java', sourcePattern: '**/src/main/java'
findBuildScans()
recordIssues(tools: [java()])
recordIssues(tools: [javaDoc()])
// if (fileExists('')) {
// recordIssues(tools: [errorProne(pattern: 'ReportFilePattern', reportEncoding: 'UTF-8')])
// } else {
// echo 'No ErrorProne report available'
// }
if (fileExists('**/build/reports/checkstyle/*.xml')) {
recordIssues(tools: [checkStyle(pattern: '**/build/reports/checkstyle/*.xml')])
} else {
echo 'No CheckStyle report available'
}
if (fileExists('**/build/reports/pmd/*.xml')) {
recordIssues(tools: [pmdParser(pattern: '**/build/reports/pmd/*.xml')])
} else {
echo 'No PMD report available'
}
if (fileExists('*/build/reports/findbugs/*.xml')) {
recordIssues(tools: [findBugs(pattern: '*/build/reports/findbugs/*.xml', useRankAsPriority: true)])
} else {
echo 'No FindBugs report available'
}
}
when { expression { fileExists('**/build/reports/spotbugs/*.xml') } }
steps {
recordIssues(tools: [spotBugs(pattern: '**/build/reports/spotbugs/*.xml', useRankAsPriority: true)])
}
when { expression { fileExists('**/build/test-results/junit-platform/*.xml') } }
steps {
recordIssues(tools: [junitParser(pattern: '**/build/test-results/junit-platform/*.xml')])
}
when { expression { fileExists('**/sonar-report.json') } }
steps {
recordIssues(tools: [sonarQube(pattern: '**/sonar-report.json')])
}
}
}
}