Jenkinsfile 5.6 KB

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