2
0

Jenkinsfile 5.6 KB

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