2
0

Jenkinsfile 6.1 KB

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