Jenkinsfile 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. try {
  10. parallel check: {
  11. stage('Check') {
  12. node {
  13. checkout scm
  14. try {
  15. sh "./gradlew clean check --refresh-dependencies --no-daemon --stacktrace"
  16. } catch(Exception e) {
  17. currentBuild.result = 'FAILED: check'
  18. throw e
  19. } finally {
  20. junit '**/build/*-results/*.xml'
  21. }
  22. }
  23. }
  24. },
  25. sonar: {
  26. stage('Sonar') {
  27. node {
  28. checkout scm
  29. withCredentials([string(credentialsId: 'spring-sonar.login', variable: 'SONAR_LOGIN')]) {
  30. try {
  31. sh "./gradlew clean sonarqube -PexcludeProjects='**/samples/**' -Dsonar.host.url=$SPRING_SONAR_HOST_URL -Dsonar.login=$SONAR_LOGIN --refresh-dependencies --no-daemon --stacktrace"
  32. } catch(Exception e) {
  33. currentBuild.result = 'FAILED: sonar'
  34. throw e
  35. }
  36. }
  37. }
  38. }
  39. },
  40. springio: {
  41. stage('Spring IO') {
  42. node {
  43. checkout scm
  44. try {
  45. sh "./gradlew clean springIoCheck -PplatformVersion=Cairo-BUILD-SNAPSHOT -PexcludeProjects='**/samples/**' --refresh-dependencies --no-daemon --stacktrace"
  46. } catch(Exception e) {
  47. currentBuild.result = 'FAILED: springio'
  48. throw e
  49. } finally {
  50. junit '**/build/spring-io*-results/*.xml'
  51. }
  52. }
  53. }
  54. },
  55. snapshots: {
  56. stage('Snapshot Tests') {
  57. node {
  58. checkout scm
  59. try {
  60. sh "./gradlew clean test -PspringVersion='5.+' -PreactorVersion=Bismuth-BUILD-SNAPSHOT -PspringDataVersion=Kay-BUILD-SNAPSHOT --refresh-dependencies --no-daemon --stacktrace"
  61. } catch(Exception e) {
  62. currentBuild.result = 'FAILED: snapshots'
  63. throw e
  64. }
  65. }
  66. }
  67. },
  68. jdk9: {
  69. stage('JDK 9') {
  70. node {
  71. checkout scm
  72. try {
  73. withEnv(["JAVA_HOME=${ tool 'jdk9' }"]) {
  74. sh "./gradlew clean test --no-daemon --stacktrace"
  75. }
  76. } catch(Exception e) {
  77. currentBuild.result = 'FAILED: jdk9'
  78. throw e
  79. }
  80. }
  81. }
  82. },
  83. jdk10: {
  84. stage('JDK 10') {
  85. node {
  86. checkout scm
  87. try {
  88. withEnv(["JAVA_HOME=${ tool 'jdk10' }"]) {
  89. sh "./gradlew clean test --no-daemon --stacktrace"
  90. }
  91. } catch(Exception e) {
  92. currentBuild.result = 'FAILED: jdk10'
  93. throw e
  94. }
  95. }
  96. }
  97. },
  98. jdk11: {
  99. stage('JDK 11') {
  100. node {
  101. checkout scm
  102. try {
  103. withEnv(["JAVA_HOME=${ tool 'jdk11' }"]) {
  104. sh "./gradlew clean test --no-daemon --stacktrace"
  105. }
  106. } catch(Exception e) {
  107. currentBuild.result = 'FAILED: jdk11'
  108. throw e
  109. }
  110. }
  111. }
  112. }
  113. if(currentBuild.result == 'SUCCESS') {
  114. parallel artifacts: {
  115. stage('Deploy Artifacts') {
  116. node {
  117. checkout scm
  118. withCredentials([file(credentialsId: 'spring-signing-secring.gpg', variable: 'SIGNING_KEYRING_FILE')]) {
  119. withCredentials([string(credentialsId: 'spring-gpg-passphrase', variable: 'SIGNING_PASSWORD')]) {
  120. withCredentials([usernamePassword(credentialsId: 'oss-token', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USERNAME')]) {
  121. withCredentials([usernamePassword(credentialsId: '02bd1690-b54f-4c9f-819d-a77cb7a9822c', usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
  122. 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"
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129. },
  130. docs: {
  131. stage('Deploy Docs') {
  132. node {
  133. checkout scm
  134. withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
  135. sh "./gradlew deployDocs -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace"
  136. }
  137. }
  138. }
  139. },
  140. schema: {
  141. stage('Deploy Schema') {
  142. node {
  143. checkout scm
  144. withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
  145. sh "./gradlew deploySchema -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace"
  146. }
  147. }
  148. }
  149. }
  150. }
  151. } finally {
  152. def buildStatus = currentBuild.result
  153. def buildNotSuccess = !SUCCESS.equals(buildStatus)
  154. def lastBuildNotSuccess = !SUCCESS.equals(currentBuild.previousBuild?.result)
  155. if(buildNotSuccess || lastBuildNotSuccess) {
  156. stage('Notifiy') {
  157. node {
  158. final def RECIPIENTS = [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']]
  159. def subject = "${buildStatus}: Build ${env.JOB_NAME} ${env.BUILD_NUMBER} status is now ${buildStatus}"
  160. def details = """The build status changed to ${buildStatus}. For details see ${env.BUILD_URL}"""
  161. emailext (
  162. subject: subject,
  163. body: details,
  164. recipientProviders: RECIPIENTS,
  165. to: "$SPRING_SECURITY_TEAM_EMAILS"
  166. )
  167. }
  168. }
  169. }
  170. }