|
| 1 | +properties([ |
| 2 | + buildDiscarder(logRotator(numToKeepStr: '10')), |
| 3 | + pipelineTriggers([ |
| 4 | + cron('@daily') |
| 5 | + ]), |
| 6 | +]) |
| 7 | + |
| 8 | +def SUCCESS = hudson.model.Result.SUCCESS.toString() |
| 9 | +currentBuild.result = SUCCESS |
| 10 | + |
| 11 | +try { |
| 12 | + parallel check: { |
| 13 | + stage('Check') { |
| 14 | + timeout(time: 45, unit: 'MINUTES') { |
| 15 | + node('linux') { |
| 16 | + label 'spring-session' |
| 17 | + checkout scm |
| 18 | + sh "git clean -dfx" |
| 19 | + try { |
| 20 | + withEnv(["JAVA_HOME=${tool 'jdk8'}"]) { |
| 21 | + sh './gradlew clean check --no-daemon --stacktrace' |
| 22 | + } |
| 23 | + } |
| 24 | + catch (e) { |
| 25 | + currentBuild.result = 'FAILED: check' |
| 26 | + throw e |
| 27 | + } |
| 28 | + finally { |
| 29 | + junit '**/build/test-results/*/*.xml' |
| 30 | + } |
| 31 | + } |
| 32 | + } |
| 33 | + } |
| 34 | + }, |
| 35 | + jdk11: { |
| 36 | + stage('JDK 11') { |
| 37 | + timeout(time: 45, unit: 'MINUTES') { |
| 38 | + node('linux') { |
| 39 | + checkout scm |
| 40 | + sh "git clean -dfx" |
| 41 | + try { |
| 42 | + withEnv(["JAVA_HOME=${tool 'jdk11'}"]) { |
| 43 | + sh './gradlew clean test integrationTest --no-daemon --stacktrace' |
| 44 | + } |
| 45 | + } |
| 46 | + catch (e) { |
| 47 | + currentBuild.result = 'FAILED: jdk11' |
| 48 | + throw e |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + }, |
| 54 | + jdk12: { |
| 55 | + stage('JDK 12') { |
| 56 | + timeout(time: 45, unit: 'MINUTES') { |
| 57 | + node('linux') { |
| 58 | + checkout scm |
| 59 | + try { |
| 60 | + withEnv(["JAVA_HOME=${tool 'openjdk12'}"]) { |
| 61 | + sh './gradlew clean test integrationTest --no-daemon --stacktrace' |
| 62 | + } |
| 63 | + } |
| 64 | + catch (e) { |
| 65 | + currentBuild.result = 'FAILED: jdk12' |
| 66 | + throw e |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + if (currentBuild.result == 'SUCCESS') { |
| 74 | + parallel artifacts: { |
| 75 | + stage('Deploy Artifacts') { |
| 76 | + node('linux') { |
| 77 | + checkout scm |
| 78 | + sh "git clean -dfx" |
| 79 | + try { |
| 80 | + withCredentials([file(credentialsId: 'spring-signing-secring.gpg', variable: 'SIGNING_KEYRING_FILE')]) { |
| 81 | + withCredentials([string(credentialsId: 'spring-gpg-passphrase', variable: 'SIGNING_PASSWORD')]) { |
| 82 | + withCredentials([usernamePassword(credentialsId: 'oss-token', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USERNAME')]) { |
| 83 | + withCredentials([usernamePassword(credentialsId: '02bd1690-b54f-4c9f-819d-a77cb7a9822c', usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) { |
| 84 | + withEnv(["JAVA_HOME=${tool 'jdk8'}"]) { |
| 85 | + sh './gradlew deployArtifacts --no-daemon --stacktrace -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' |
| 86 | + sh './gradlew finalizeDeployArtifacts --no-daemon --stacktrace -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' |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + } |
| 93 | + catch (e) { |
| 94 | + currentBuild.result = 'FAILED: artifacts' |
| 95 | + throw e |
| 96 | + } |
| 97 | + } |
| 98 | + } |
| 99 | + }, |
| 100 | + docs: { |
| 101 | + stage('Deploy Docs') { |
| 102 | + node('linux') { |
| 103 | + checkout scm |
| 104 | + sh "git clean -dfx" |
| 105 | + try { |
| 106 | + withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) { |
| 107 | + withEnv(["JAVA_HOME=${tool 'jdk8'}"]) { |
| 108 | + sh './gradlew deployDocs --no-daemon --stacktrace -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME' |
| 109 | + } |
| 110 | + } |
| 111 | + } |
| 112 | + catch (e) { |
| 113 | + currentBuild.result = 'FAILED: docs' |
| 114 | + throw e |
| 115 | + } |
| 116 | + } |
| 117 | + } |
| 118 | + } |
| 119 | + } |
| 120 | +} |
| 121 | +finally { |
| 122 | + def buildStatus = currentBuild.result |
| 123 | + def buildNotSuccess = !SUCCESS.equals(buildStatus) |
| 124 | + def lastBuildNotSuccess = !SUCCESS.equals(currentBuild.previousBuild?.result) |
| 125 | + |
| 126 | + if (buildNotSuccess || lastBuildNotSuccess) { |
| 127 | + stage('Notify') { |
| 128 | + node { |
| 129 | + final def RECIPIENTS = [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']] |
| 130 | + |
| 131 | + def subject = "${buildStatus}: Build ${env.JOB_NAME} ${env.BUILD_NUMBER} status is now ${buildStatus}" |
| 132 | + def details = "The build status changed to ${buildStatus}. For details see ${env.BUILD_URL}" |
| 133 | + |
| 134 | + emailext( |
| 135 | + subject: subject, |
| 136 | + body: details, |
| 137 | + recipientProviders: RECIPIENTS, |
| 138 | + to: "$SPRING_SESSION_TEAM_EMAILS" |
| 139 | + ) |
| 140 | + } |
| 141 | + } |
| 142 | + } |
| 143 | +} |
0 commit comments