Jenkinsfile 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 test --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. if(currentBuild.result == 'SUCCESS') {
  29. parallel artifacts: {
  30. stage('Deploy Artifacts') {
  31. node {
  32. checkout scm
  33. sh "git clean -dfx"
  34. withCredentials([file(credentialsId: 'spring-signing-secring.gpg', variable: 'SIGNING_KEYRING_FILE')]) {
  35. withCredentials([string(credentialsId: 'spring-gpg-passphrase', variable: 'SIGNING_PASSWORD')]) {
  36. withCredentials([usernamePassword(credentialsId: 'oss-token', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USERNAME')]) {
  37. withCredentials([usernamePassword(credentialsId: '02bd1690-b54f-4c9f-819d-a77cb7a9822c', usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
  38. withEnv(["JAVA_HOME=${ tool 'jdk8' }"]) {
  39. 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"
  40. }
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }
  47. },
  48. docs: {
  49. stage('Deploy Docs') {
  50. node {
  51. checkout scm
  52. sh "git clean -dfx"
  53. withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
  54. withEnv(["JAVA_HOME=${ tool 'jdk8' }"]) {
  55. sh "./gradlew deployDocs -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace"
  56. }
  57. }
  58. }
  59. }
  60. },
  61. schema: {
  62. stage('Deploy Schema') {
  63. node {
  64. checkout scm
  65. sh "git clean -dfx"
  66. withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
  67. withEnv(["JAVA_HOME=${ tool 'jdk8' }"]) {
  68. sh "./gradlew deploySchema -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace"
  69. }
  70. }
  71. }
  72. }
  73. }
  74. }
  75. } catch(Exception e) {
  76. currentBuild.result = 'FAILED: deploys'
  77. throw e
  78. } finally {
  79. def buildStatus = currentBuild.result
  80. def buildNotSuccess = !SUCCESS.equals(buildStatus)
  81. def lastBuildNotSuccess = !SUCCESS.equals(currentBuild.previousBuild?.result)
  82. if(buildNotSuccess || lastBuildNotSuccess) {
  83. stage('Notifiy') {
  84. node {
  85. final def RECIPIENTS = [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']]
  86. def subject = "${buildStatus}: Build ${env.JOB_NAME} ${env.BUILD_NUMBER} status is now ${buildStatus}"
  87. def details = """The build status changed to ${buildStatus}. For details see ${env.BUILD_URL}"""
  88. emailext (
  89. subject: subject,
  90. body: details,
  91. recipientProviders: RECIPIENTS,
  92. to: "$SPRING_SECURITY_TEAM_EMAILS"
  93. )
  94. }
  95. }
  96. }
  97. }