Jenkinsfile 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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=Californium-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. if(currentBuild.result == 'SUCCESS') {
  103. parallel artifacts: {
  104. stage('Deploy Artifacts') {
  105. node {
  106. checkout scm
  107. withCredentials([file(credentialsId: 'spring-signing-secring.gpg', variable: 'SIGNING_KEYRING_FILE')]) {
  108. withCredentials([string(credentialsId: 'spring-gpg-passphrase', variable: 'SIGNING_PASSWORD')]) {
  109. withCredentials([usernamePassword(credentialsId: 'oss-token', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USERNAME')]) {
  110. withCredentials([usernamePassword(credentialsId: '02bd1690-b54f-4c9f-819d-a77cb7a9822c', usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
  111. 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"
  112. }
  113. }
  114. }
  115. }
  116. }
  117. }
  118. },
  119. docs: {
  120. stage('Deploy Docs') {
  121. node {
  122. checkout scm
  123. withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
  124. sh "./gradlew deployDocs -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace"
  125. }
  126. }
  127. }
  128. },
  129. schema: {
  130. stage('Deploy Schema') {
  131. node {
  132. checkout scm
  133. withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
  134. sh "./gradlew deploySchema -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace"
  135. }
  136. }
  137. }
  138. }
  139. }
  140. } catch(Exception e) {
  141. currentBuild.result = 'FAILED: deploys'
  142. throw e
  143. } finally {
  144. def buildStatus = currentBuild.result
  145. def buildNotSuccess = !SUCCESS.equals(buildStatus)
  146. def lastBuildNotSuccess = !SUCCESS.equals(currentBuild.previousBuild?.result)
  147. if(buildNotSuccess || lastBuildNotSuccess) {
  148. stage('Notifiy') {
  149. node {
  150. final def RECIPIENTS = [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']]
  151. def subject = "${buildStatus}: Build ${env.JOB_NAME} ${env.BUILD_NUMBER} status is now ${buildStatus}"
  152. def details = """The build status changed to ${buildStatus}. For details see ${env.BUILD_URL}"""
  153. emailext (
  154. subject: subject,
  155. body: details,
  156. recipientProviders: RECIPIENTS,
  157. to: "$SPRING_SECURITY_TEAM_EMAILS"
  158. )
  159. }
  160. }
  161. }
  162. }