-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile.spring-boot
79 lines (77 loc) · 3.1 KB
/
Jenkinsfile.spring-boot
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
#!groovy
pipeline {
agent { node { label 'linux' } }
environment{
GRADLE_HOME = fileExists "$HOME/.gradle"
}
options {
buildDiscarder logRotator( numToKeepStr: '20' )
}
parameters {
string( defaultValue: '12.0.3-SNAPSHOT', description: 'Jetty version to use to build SpringBoot project',
name: 'JETTY_VERSION' )
string( defaultValue: 'jdk17', description: 'JDK to use (jdk8,jdk11,jdk17,jdk21)', name: 'JDK' )
string( defaultValue: 'spring-projects', description: 'github org to use', name: 'GITHUB_ORG' )
string( defaultValue: 'main', description: 'springboot branch', name: 'SPRINGBOOT_BRANCH' )
}
stages {
stage('Create Gradle home'){
when { expression { GRADLE_HOME == 'false' } }
steps {
sh "mkdir $HOME/.gradle"
}
}
stage("Checkout SpringBoot"){
steps{
stash name: 'init.gradle.spring-framework', includes: 'init.gradle.spring-framework'
checkout([$class: 'GitSCM',
branches: [[name: "*/$SPRINGBOOT_BRANCH"]],
extensions: [[$class: 'CloneOption', depth: 1, noTags: true, shallow: true]],
userRemoteConfigs: [[url: 'https://github.com/${GITHUB_ORG}/spring-boot.git']]])
}
}
stage("Build SpringBoot"){
steps{
getBuild("${SPRINGBOOT_BRANCH}", "$jdk")
}
post {
always {
script{
currentBuild.description = "Build SpringBoot branch ${GITHUB_ORG}/${SPRINGBOOT_BRANCH}, Jetty Version ${JETTY_VERSION}, jdk ${jdk}"
}
junit testResults: '**/build/test-results/test/*.xml', allowEmptyResults: true
archiveArtifacts artifacts: "spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build/reports/**", allowEmptyArchive: true
publishHTML( [allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true,
reportDir: "buildSrc/build/reports/tests/test",
reportFiles: 'index.html', reportName: 'Build Report', reportTitles: ''] )
}
}
}
}
}
def getBuild(branch,jdk){
if(branch=='2.2.x'){
withEnv(["JAVA_HOME=${ tool "$jdk" }"]) {
withMaven( maven: 'maven3',
jdk: "$jdk",
publisherStrategy: 'EXPLICIT',
mavenOpts: '-Xms4g -Xmx8g' ) {
sh "./mvnw -V -B -U clean install -Dmaven.test.failure.ignore=true -Dgradle.task=assemble -Djetty.version=${JETTY_VERSION}"
}
}
} else {
withEnv(["JAVA_HOME=${ tool "$jdk" }"]) {
configFileProvider([configFile(fileId: 'init.gradle', variable: 'INIT_GRADLE')]) {
sh "cp $INIT_GRADLE $HOME/.gradle/init.gradle"
unstash name: 'init.gradle.spring-framework'
script{
def text = readFile "init.gradle.spring-framework"
text = text.replaceAll("9.4.29.v20200521", "${JETTY_VERSION}")
writeFile file:"init.gradle.spring-framework.modified", text: text
}
sh "cat init.gradle.spring-framework.modified"
sh './gradlew build --info --no-daemon --no-build-cache --init-script init.gradle.spring-framework'
}
}
}
}