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.

94 lines
3.5 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. #!/usr/bin/env 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. script {
  15. def commitId = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
  16. def commitDate = sh(returnStdout: true, script: 'git --no-pager show -s --format=%cd --date=short HEAD').trim()
  17. REVISION = "${env.BRANCH_NAME}-${commitDate}.${commitId}"
  18. }
  19. sh "chmod -R +x ."
  20. sh "./gradlew -Pversion='${REVISION}' testClasses"
  21. }
  22. }
  23. stage('Test') {
  24. steps {
  25. sh "./gradlew --no-build-cache -Pversion='${REVISION}' -Dtestlogger.theme=plain-parallel test"
  26. }
  27. post {
  28. always {
  29. junit '**/build/test-results/test/TEST-*.xml'
  30. }
  31. }
  32. }
  33. stage('Package') {
  34. steps {
  35. sh "./gradlew -Pversion='${REVISION}' jar -x test"
  36. }
  37. }
  38. }
  39. post {
  40. always {
  41. script {
  42. def commit = sh(returnStdout: true, script: 'git rev-parse HEAD')
  43. def author = sh(returnStdout: true, script: "git --no-pager show -s --format='%an' ${commit}").trim()
  44. def commitLog = sh(returnStdout: true, script: 'git log -1 --pretty=%B').trim()
  45. CUSTOM_SCM_INFO = "Latest Commit (${author}):```${commitLog}```"
  46. }
  47. deleteDir()
  48. }
  49. success {
  50. // script {
  51. //
  52. // sh "'${env.BRANCH_NAME}'"
  53. // if (${env.BRANCH_NAME}.startsWith('pr-')) {
  54. //
  55. //// git url: "git@gogs.informatik.hs-fulda.de:SteffenN/Multi-Chess.git",
  56. //// credentialsId: 'jenkins_ssh_key',
  57. //// branch: (env.BRANCH_NAME)
  58. //
  59. // sh "git merge '${env.BRANCH_NAME}'"
  60. // sh "git commit -am 'Merged ${env.BRANCH_NAME} branch to master'"
  61. // sh "git push origin master"
  62. // }
  63. // }
  64. office365ConnectorSend color: 'good',
  65. message: "Build ${currentBuild.fullDisplayName} completed *successfully* (<${BUILD_URL}>).\n\n\n${CUSTOM_SCM_INFO}",
  66. webhookUrl: "https://outlook.office.com/webhook/97618564-835e-438e-a2a7-a77b21331e1e@22877e52-e9fd-410d-91a3-817d8ab89d63/JenkinsCI/fa736de2175649a891c2957f00532027/87d23462-1d0c-4378-b4e0-05c7d5546a25"
  67. }
  68. failure {
  69. office365ConnectorSend color: 'danger',
  70. message: "Build ${currentBuild.fullDisplayName} *failed* (<${BUILD_URL}>).\n\n\n${CUSTOM_SCM_INFO}",
  71. webhookUrl: "https://outlook.office.com/webhook/97618564-835e-438e-a2a7-a77b21331e1e@22877e52-e9fd-410d-91a3-817d8ab89d63/JenkinsCI/fa736de2175649a891c2957f00532027/87d23462-1d0c-4378-b4e0-05c7d5546a25"
  72. }
  73. unstable {
  74. office365ConnectorSend color: 'warning',
  75. message: "Build ${currentBuild.fullDisplayName} was *unstable* (<${env.BUILD_URL}>).\n\n\n${CUSTOM_SCM_INFO}",
  76. webhookUrl: "https://outlook.office.com/webhook/97618564-835e-438e-a2a7-a77b21331e1e@22877e52-e9fd-410d-91a3-817d8ab89d63/JenkinsCI/fa736de2175649a891c2957f00532027/87d23462-1d0c-4378-b4e0-05c7d5546a25"
  77. }
  78. }
  79. }