Jenkinsfile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. def projectProperties = [
  2. [$class: 'BuildDiscarderProperty',
  3. strategy: [$class: 'LogRotator', numToKeepStr: '5']],
  4. pipelineTriggers([cron('@daily')])
  5. ]
  6. properties(projectProperties)
  7. def SUCCESS = hudson.model.Result.SUCCESS.toString()
  8. currentBuild.result = SUCCESS
  9. def ARTIFACTORY_CREDENTIALS = usernamePassword(credentialsId: '02bd1690-b54f-4c9f-819d-a77cb7a9822c', usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')
  10. try {
  11. parallel check: {
  12. stage('Check') {
  13. node {
  14. checkout scm
  15. sh "git clean -dfx"
  16. try {
  17. withCredentials([ARTIFACTORY_CREDENTIALS]) {
  18. withEnv(["JAVA_HOME=${ tool 'jdk8' }"]) {
  19. sh "./gradlew test -PartifactoryUsername=$ARTIFACTORY_USERNAME -PartifactoryPassword=$ARTIFACTORY_PASSWORD --refresh-dependencies --no-daemon --stacktrace"
  20. }
  21. }
  22. } catch(Exception e) {
  23. currentBuild.result = 'FAILED: check'
  24. throw e
  25. } finally {
  26. junit '**/build/test-results/*/*.xml'
  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([ARTIFACTORY_CREDENTIALS]) {
  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. if(buildNotSuccess || lastBuildNotSuccess) {
  86. stage('Notifiy') {
  87. node {
  88. final def RECIPIENTS = [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']]
  89. def subject = "${buildStatus}: Build ${env.JOB_NAME} ${env.BUILD_NUMBER} status is now ${buildStatus}"
  90. def details = """The build status changed to ${buildStatus}. For details see ${env.BUILD_URL}"""
  91. emailext (
  92. subject: subject,
  93. body: details,
  94. recipientProviders: RECIPIENTS,
  95. to: "$SPRING_SECURITY_TEAM_EMAILS"
  96. )
  97. }
  98. }
  99. }
  100. }