Jenkinsfile 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 docs: {
  57. stage('Deploy Docs') {
  58. node {
  59. checkout scm
  60. withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
  61. sh "./gradlew deployDocs -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace"
  62. }
  63. }
  64. }
  65. },
  66. schema: {
  67. stage('Deploy Schema') {
  68. node {
  69. checkout scm
  70. withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) {
  71. sh "./gradlew deploySchema -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace"
  72. }
  73. }
  74. }
  75. }
  76. }
  77. } finally {
  78. def buildStatus = currentBuild.result
  79. def buildNotSuccess = !SUCCESS.equals(buildStatus)
  80. def lastBuildNotSuccess = !SUCCESS.equals(currentBuild.previousBuild?.result)
  81. if(buildNotSuccess || lastBuildNotSuccess) {
  82. stage('Notifiy') {
  83. node {
  84. final def RECIPIENTS = [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']]
  85. def subject = "${buildStatus}: Build ${env.JOB_NAME} ${env.BUILD_NUMBER} status is now ${buildStatus}"
  86. def details = """The build status changed to ${buildStatus}. For details see ${env.BUILD_URL}"""
  87. emailext (
  88. subject: subject,
  89. body: details,
  90. recipientProviders: RECIPIENTS,
  91. to: "$SPRING_SECURITY_TEAM_EMAILS"
  92. )
  93. }
  94. }
  95. }
  96. }