Skip to content

Commit 535160b

Browse files
committed
Update Jenkinsfile
- set check stage timeout to 30 minutes - set build discared to keep last 10 builds - handle deploy stage errors - general formatting improvements
1 parent 606e080 commit 535160b

File tree

1 file changed

+55
-37
lines changed

1 file changed

+55
-37
lines changed

Jenkinsfile

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
def projectProperties = [
2-
[$class: 'BuildDiscarderProperty',
3-
strategy: [$class: 'LogRotator', numToKeepStr: '5']],
4-
pipelineTriggers([cron('@daily')])
5-
]
6-
properties(projectProperties)
1+
properties([
2+
buildDiscarder(logRotator(numToKeepStr: '10')),
3+
pipelineTriggers([
4+
cron('@daily')
5+
]),
6+
])
77

88
def SUCCESS = hudson.model.Result.SUCCESS.toString()
99
currentBuild.result = SUCCESS
1010

1111
try {
1212
parallel check: {
1313
stage('Check') {
14-
node {
15-
checkout scm
16-
try {
17-
sh "./gradlew clean check --refresh-dependencies --no-daemon"
18-
} catch(Exception e) {
19-
currentBuild.result = 'FAILED: check'
20-
throw e
21-
} finally {
22-
junit '**/build/*-results/*.xml'
14+
timeout(time: 30, unit: 'MINUTES') {
15+
node {
16+
checkout scm
17+
try {
18+
sh './gradlew clean check --no-daemon --refresh-dependencies'
19+
}
20+
catch (e) {
21+
currentBuild.result = 'FAILED: check'
22+
throw e
23+
}
24+
finally {
25+
junit '**/build/*-results/*.xml'
26+
}
2327
}
2428
}
2529
}
@@ -29,64 +33,78 @@ try {
2933
node {
3034
checkout scm
3135
try {
32-
sh "./gradlew clean springIoCheck -PplatformVersion=Cairo-BUILD-SNAPSHOT -PexcludeProjects='**/samples/**' --refresh-dependencies --no-daemon --stacktrace"
33-
} catch(Exception e) {
36+
sh './gradlew clean springIoCheck --stacktrace --no-daemon --refresh-dependencies -PplatformVersion=Cairo-BUILD-SNAPSHOT -PexcludeProjects='**/samples/**'
37+
}
38+
catch(e) {
3439
currentBuild.result = 'FAILED: springio'
3540
throw e
36-
} finally {
41+
}
42+
finally {
3743
junit '**/build/spring-io*-results/*.xml'
3844
}
3945
}
4046
}
4147
}
4248
43-
if(currentBuild.result == 'SUCCESS') {
49+
if (currentBuild.result == 'SUCCESS') {
4450
parallel artifacts: {
4551
stage('Deploy Artifacts') {
4652
node {
4753
checkout scm
48-
withCredentials([file(credentialsId: 'spring-signing-secring.gpg', variable: 'SIGNING_KEYRING_FILE')]) {
49-
withCredentials([string(credentialsId: 'spring-gpg-passphrase', variable: 'SIGNING_PASSWORD')]) {
50-
withCredentials([usernamePassword(credentialsId: 'oss-token', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USERNAME')]) {
51-
withCredentials([usernamePassword(credentialsId: '02bd1690-b54f-4c9f-819d-a77cb7a9822c', usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
52-
sh "./gradlew deployArtifacts finalizeDeployArtifacts -Psigning.secretKeyRingFile=$SIGNING_KEYRING_FILE -Psigning.keyId=$SPRING_SIGNING_KEYID -Psigning.password='$SIGNING_PASSWORD' -PossrhUsername=$OSSRH_USERNAME -PossrhPassword=$OSSRH_PASSWORD -PartifactoryUsername=$ARTIFACTORY_USERNAME -PartifactoryPassword=$ARTIFACTORY_PASSWORD --refresh-dependencies --no-daemon --stacktrace"
54+
try {
55+
withCredentials([file(credentialsId: 'spring-signing-secring.gpg', variable: 'SIGNING_KEYRING_FILE')]) {
56+
withCredentials([string(credentialsId: 'spring-gpg-passphrase', variable: 'SIGNING_PASSWORD')]) {
57+
withCredentials([usernamePassword(credentialsId: 'oss-token', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USERNAME')]) {
58+
withCredentials([usernamePassword(credentialsId: '02bd1690-b54f-4c9f-819d-a77cb7a9822c', usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
59+
sh './gradlew deployArtifacts finalizeDeployArtifacts --stacktrace --no-daemon --refresh-dependencies -Psigning.secretKeyRingFile=$SIGNING_KEYRING_FILE -Psigning.keyId=$SPRING_SIGNING_KEYID -Psigning.password=$SIGNING_PASSWORD -PossrhUsername=$OSSRH_USERNAME -PossrhPassword=$OSSRH_PASSWORD -PartifactoryUsername=$ARTIFACTORY_USERNAME -PartifactoryPassword=$ARTIFACTORY_PASSWORD'
60+
}
5361
}
5462
}
5563
}
5664
}
65+
catch (e) {
66+
currentBuild.result = 'FAILED: artifacts'
67+
throw e
68+
}
5769
}
5870
}
5971
},
6072
docs: {
6173
stage('Deploy Docs') {
6274
node {
6375
checkout scm
64-
withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
65-
sh "./gradlew deployDocs -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace"
76+
try {
77+
withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
78+
sh './gradlew deployDocs --stacktrace --no-daemon --refresh-dependencies -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME'
79+
}
80+
}
81+
catch (e) {
82+
currentBuild.result = 'FAILED: docs'
83+
throw e
6684
}
6785
}
6886
}
6987
}
7088
}
71-
} finally {
89+
}
90+
finally {
7291
def buildStatus = currentBuild.result
73-
def buildNotSuccess = !SUCCESS.equals(buildStatus)
92+
def buildNotSuccess = !SUCCESS.equals(buildStatus)
7493
def lastBuildNotSuccess = !SUCCESS.equals(currentBuild.previousBuild?.result)
7594
76-
if(buildNotSuccess || lastBuildNotSuccess) {
77-
78-
stage('Notifiy') {
95+
if (buildNotSuccess || lastBuildNotSuccess) {
96+
stage('Notify') {
7997
node {
8098
final def RECIPIENTS = [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']]
8199
82100
def subject = "${buildStatus}: Build ${env.JOB_NAME} ${env.BUILD_NUMBER} status is now ${buildStatus}"
83-
def details = """The build status changed to ${buildStatus}. For details see ${env.BUILD_URL}"""
101+
def details = "The build status changed to ${buildStatus}. For details see ${env.BUILD_URL}"
84102
85-
emailext (
86-
subject: subject,
87-
body: details,
88-
recipientProviders: RECIPIENTS,
89-
to: "$SPRING_SESSION_TEAM_EMAILS"
103+
emailext(
104+
subject: subject,
105+
body: details,
106+
recipientProviders: RECIPIENTS,
107+
to: "$SPRING_SESSION_TEAM_EMAILS"
90108
)
91109
}
92110
}

0 commit comments

Comments
 (0)