|
| 1 | +def projectProperties = [ |
| 2 | + [$class: 'BuildDiscarderProperty', |
| 3 | + strategy: [$class: 'LogRotator', numToKeepStr: '5']], |
| 4 | + pipelineTriggers([cron('@daily')]) |
| 5 | +] |
| 6 | +properties(projectProperties) |
| 7 | + |
| 8 | +def SUCCESS = hudson.model.Result.SUCCESS.toString() |
| 9 | +currentBuild.result = SUCCESS |
| 10 | + |
| 11 | +try { |
| 12 | + parallel check: { |
| 13 | + stage('Check') { |
| 14 | + node { |
| 15 | + checkout scm |
| 16 | + sh "git clean -dfx" |
| 17 | + try { |
| 18 | + withEnv(["JAVA_HOME=${ tool 'jdk8' }"]) { |
| 19 | + sh "./gradlew test --refresh-dependencies --no-daemon --stacktrace" |
| 20 | + } |
| 21 | + } catch(Exception e) { |
| 22 | + currentBuild.result = 'FAILED: check' |
| 23 | + throw e |
| 24 | + } finally { |
| 25 | + junit '**/build/test-results/*/*.xml' |
| 26 | + } |
| 27 | + } |
| 28 | + } |
| 29 | + } |
| 30 | + |
| 31 | + if(currentBuild.result == 'SUCCESS') { |
| 32 | + parallel artifacts: { |
| 33 | + stage('Deploy Artifacts') { |
| 34 | + node { |
| 35 | + checkout scm |
| 36 | + sh "git clean -dfx" |
| 37 | + withCredentials([file(credentialsId: 'spring-signing-secring.gpg', variable: 'SIGNING_KEYRING_FILE')]) { |
| 38 | + withCredentials([string(credentialsId: 'spring-gpg-passphrase', variable: 'SIGNING_PASSWORD')]) { |
| 39 | + withCredentials([usernamePassword(credentialsId: 'oss-token', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USERNAME')]) { |
| 40 | + withCredentials([usernamePassword(credentialsId: '02bd1690-b54f-4c9f-819d-a77cb7a9822c', usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) { |
| 41 | + withEnv(["JAVA_HOME=${ tool 'jdk8' }"]) { |
| 42 | + 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" |
| 43 | + } |
| 44 | + } |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | + } |
| 49 | + } |
| 50 | + }, |
| 51 | + docs: { |
| 52 | + stage('Deploy Docs') { |
| 53 | + node { |
| 54 | + checkout scm |
| 55 | + sh "git clean -dfx" |
| 56 | + withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) { |
| 57 | + withEnv(["JAVA_HOME=${ tool 'jdk8' }"]) { |
| 58 | + sh "./gradlew deployDocs -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace" |
| 59 | + } |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | + }, |
| 64 | + schema: { |
| 65 | + stage('Deploy Schema') { |
| 66 | + node { |
| 67 | + checkout scm |
| 68 | + sh "git clean -dfx" |
| 69 | + withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) { |
| 70 | + withEnv(["JAVA_HOME=${ tool 'jdk8' }"]) { |
| 71 | + sh "./gradlew deploySchema -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace" |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + } |
| 76 | + } |
| 77 | + } |
| 78 | +} catch(Exception e) { |
| 79 | + currentBuild.result = 'FAILED: deploys' |
| 80 | + throw e |
| 81 | +} finally { |
| 82 | + def buildStatus = currentBuild.result |
| 83 | + def buildNotSuccess = !SUCCESS.equals(buildStatus) |
| 84 | + def lastBuildNotSuccess = !SUCCESS.equals(currentBuild.previousBuild?.result) |
| 85 | + |
| 86 | + if(buildNotSuccess || lastBuildNotSuccess) { |
| 87 | + |
| 88 | + stage('Notifiy') { |
| 89 | + node { |
| 90 | + final def RECIPIENTS = [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']] |
| 91 | + |
| 92 | + def subject = "${buildStatus}: Build ${env.JOB_NAME} ${env.BUILD_NUMBER} status is now ${buildStatus}" |
| 93 | + def details = """The build status changed to ${buildStatus}. For details see ${env.BUILD_URL}""" |
| 94 | + |
| 95 | + emailext ( |
| 96 | + subject: subject, |
| 97 | + body: details, |
| 98 | + recipientProviders: RECIPIENTS, |
| 99 | + to: "$SPRING_SECURITY_TEAM_EMAILS" |
| 100 | + ) |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | +} |
0 commit comments