You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.4 KiB

4 years ago
  1. #!groovy
  2. pipeline {
  3. agent any
  4. options {
  5. timeout(time: 2, unit: 'HOURS')
  6. }
  7. environment {
  8. REVISION = ''
  9. CUSTOM_SCM_INFO = ''
  10. }
  11. stages {
  12. stage('Build') {
  13. steps {
  14. sh "./gradlew -Pversion='${REVISION}' testClasses"
  15. }
  16. script {
  17. def commitId = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
  18. def commitDate = sh(returnStdout: true, script: 'git --no-pager show -s --format=%cd --date=short HEAD').trim()
  19. REVISION = "${env.BRANCH_NAME}-${commitDate}.${commitId}"
  20. }
  21. }
  22. stage('Test') {
  23. steps {
  24. sh "./gradlew --no-build-cache -Pversion='${REVISION}' -Dtestlogger.theme=plain-parallel test"
  25. }
  26. post {
  27. always {
  28. junit '**/build/test-results/test/TEST-*.xml'
  29. }
  30. }
  31. }
  32. stage('Package') {
  33. steps {
  34. sh "./gradlew -Pversion='${REVISION}' bootJar -x test"
  35. }
  36. }
  37. }
  38. post {
  39. always {
  40. script {
  41. def commit = sh(returnStdout: true, script: 'git rev-parse HEAD')
  42. def author = sh(returnStdout: true, script: "git --no-pager show -s --format='%an' ${commit}").trim()
  43. def commitLog = sh(returnStdout: true, script: 'git log -1 --pretty=%B').trim()
  44. CUSTOM_SCM_INFO = "Latest Commit (${author}):```${commitLog}```"
  45. }
  46. deleteDir()
  47. }
  48. success {
  49. bitbucketStatusNotify(
  50. buildState: 'SUCCESSFUL'
  51. )
  52. office365ConnectorSend color: 'good',
  53. message: "Build ${currentBuild.fullDisplayName} completed *successfully* (<${env.BUILD_URL}|Open>).\n\n\n${CUSTOM_SCM_INFO}",
  54. webhookUrl: ""
  55. }
  56. failure {
  57. bitbucketStatusNotify(
  58. buildState: 'FAILED'
  59. )
  60. office365ConnectorSend color: 'danger',
  61. message: "Build ${currentBuild.fullDisplayName} *failed* (<${env.BUILD_URL}|Open>).\n\n\n${CUSTOM_SCM_INFO}"
  62. }
  63. unstable {
  64. office365ConnectorSend color: 'warning',
  65. message: "Build ${currentBuild.fullDisplayName} was *unstable* (<${env.BUILD_URL}|Open>).\n\n\n${CUSTOM_SCM_INFO}"
  66. }
  67. }
  68. }