Jenkinsfile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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"
  16. } catch(Exception e) {
  17. currentBuild.result = 'FAILED: check'
  18. throw e
  19. } finally {
  20. junit '**/build/*-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. sh "./gradlew clean sonarqube -PexcludeProjects='**/samples/**' -Dsonar.host.url=$SPRING_SONAR_HOST_URL -Dsonar.login=$SONAR_LOGIN --refresh-dependencies --no-daemon"
  32. } catch(Exception e) {
  33. currentBuild.result = 'FAILED: sonar'
  34. throw e
  35. }
  36. }
  37. }
  38. }
  39. },
  40. springio: {
  41. stage('Spring IO') {
  42. node {
  43. checkout scm
  44. try {
  45. sh "./gradlew clean springIoCheck -PplatformVersion=Cairo-BUILD-SNAPSHOT -PexcludeProjects='**/samples/**' --refresh-dependencies --no-daemon --stacktrace"
  46. } catch(Exception e) {
  47. currentBuild.result = 'FAILED: springio'
  48. throw e
  49. } finally {
  50. junit '**/build/spring-io*-results/*.xml'
  51. }
  52. }
  53. }
  54. }
  55. if(currentBuild.result == 'SUCCESS') {
  56. parallel artifactory: {
  57. stage('Artifactory Deploy') {
  58. node {
  59. checkout scm
  60. withCredentials([usernamePassword(credentialsId: '02bd1690-b54f-4c9f-819d-a77cb7a9822c', usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
  61. sh "./gradlew artifactoryPublish -PartifactoryUsername=$ARTIFACTORY_USERNAME -PartifactoryPassword=$ARTIFACTORY_PASSWORD --no-daemon --stacktrace"
  62. }
  63. }
  64. }
  65. },
  66. docs: {
  67. stage('Deploy Docs') {
  68. node {
  69. checkout scm
  70. withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
  71. sh "./gradlew deployDocs -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace"
  72. }
  73. }
  74. }
  75. },
  76. schema: {
  77. stage('Deploy Schema') {
  78. node {
  79. checkout scm
  80. withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
  81. sh "./gradlew deploySchema -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace"
  82. }
  83. }
  84. }
  85. }
  86. }
  87. } finally {
  88. def buildStatus = currentBuild.result
  89. def buildNotSuccess = !SUCCESS.equals(buildStatus)
  90. def lastBuildNotSuccess = !SUCCESS.equals(currentBuild.previousBuild?.result)
  91. if(buildNotSuccess || lastBuildNotSuccess) {
  92. stage('Notifiy') {
  93. node {
  94. final def RECIPIENTS = [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']]
  95. def subject = "${buildStatus}: Build ${env.JOB_NAME} ${env.BUILD_NUMBER} status is now ${buildStatus}"
  96. def details = """The build status changed to ${buildStatus}. For details see ${env.BUILD_URL}"""
  97. emailext (
  98. subject: subject,
  99. body: details,
  100. recipientProviders: RECIPIENTS,
  101. to: "$SPRING_SECURITY_TEAM_EMAILS"
  102. )
  103. }
  104. }
  105. }
  106. }