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.

Jenkinsfile 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. LABEL = 'ubuntu'
  2. buildJdk = 'JDK 1.8 (latest)'
  3. buildMvn = 'Maven 3.5.2'
  4. deploySettings = 'DefaultMavenSettingsProvider.1331204114925'
  5. pipeline {
  6. agent {
  7. label "${LABEL}"
  8. }
  9. stages {
  10. stage('Checkout') {
  11. steps {
  12. script {
  13. echo "Info: Job-Name=${JOB_NAME}, Branch=${BRANCH_NAME}, Workspace=${PWD}"
  14. }
  15. checkout scm
  16. }
  17. post {
  18. failure {
  19. notifyBuild("Checkout failure")
  20. }
  21. }
  22. }
  23. stage('Build') {
  24. steps {
  25. timeout(120) {
  26. withMaven(maven: buildMvn, jdk: buildJdk,
  27. mavenSettingsConfig: deploySettings,
  28. mavenLocalRepo: ".repository"
  29. )
  30. {
  31. sh "chmod 755 ./src/ci/scripts/prepareWorkspace.sh"
  32. sh "./src/ci/scripts/prepareWorkspace.sh"
  33. // Needs a lot of time to reload the repository files, try without cleanup
  34. // Not sure, but maybe
  35. // sh "rm -rf .repository"
  36. // Run test phase / ignore test failures
  37. // -B: Batch mode
  38. // -U: Force snapshot update
  39. // -e: Produce execution error messages
  40. // -fae: Fail at the end
  41. // -Dmaven.compiler.fork=false: Do not compile in a separate forked process
  42. // -Dmaven.test.failure.ignore=true: Do not stop, if some tests fail
  43. // -Pci-build: Profile for CI-Server
  44. sh "mvn clean install -B -U -e -fae -Dmaven.test.failure.ignore=true -T2 -Dmaven.compiler.fork=false -Pci-build"
  45. }
  46. }
  47. }
  48. post {
  49. success {
  50. junit testDataPublishers: [[$class: 'StabilityTestDataPublisher']], testResults: '**/target/surefire-reports/TEST-*.xml'
  51. archiveArtifacts '**/target/*.war,**/target/*-bin.zip'
  52. }
  53. failure {
  54. notifyBuild("Build / Test failure")
  55. }
  56. }
  57. }
  58. stage('Deploy') {
  59. steps {
  60. timeout(120) {
  61. withMaven(maven: buildMvn, jdk: buildJdk,
  62. mavenSettingsConfig: deploySettings,
  63. mavenLocalRepo: ".repository"
  64. )
  65. {
  66. sh "mvn deploy -B -Dmaven.test.skip=true"
  67. }
  68. }
  69. }
  70. post {
  71. failure {
  72. notifyBuild("Deploy failure")
  73. }
  74. }
  75. }
  76. }
  77. post {
  78. unstable {
  79. notifyBuild("Unstable Build")
  80. }
  81. always {
  82. cleanWs deleteDirs: true, notFailBuild: true, patterns: [[pattern: '.repository', type: 'EXCLUDE']]
  83. }
  84. }
  85. }
  86. // Send a notification about the build status
  87. def notifyBuild(String buildStatus) {
  88. // default the value
  89. buildStatus = buildStatus ?: "UNKNOWN"
  90. def email = "notifications@archiva.apache.org"
  91. def summary = "${env.JOB_NAME}#${env.BUILD_NUMBER} - ${buildStatus}"
  92. def detail = """<h4>Job: <a href='${env.JOB_URL}'>${env.JOB_NAME}</a> [#${env.BUILD_NUMBER}]</h4>
  93. <p><b>${buildStatus}</b></p>
  94. <table>
  95. <tr><td>Build</td><td><a href='${env.BUILD_URL}'>${env.BUILD_URL}</a></td><tr>
  96. <tr><td>Console</td><td><a href='${env.BUILD_URL}console'>${env.BUILD_URL}console</a></td><tr>
  97. <tr><td>Test Report</td><td><a href='${env.BUILD_URL}testReport/'>${env.BUILD_URL}testReport/</a></td><tr>
  98. </table>
  99. """
  100. emailext(
  101. to: email,
  102. subject: summary,
  103. body: detail,
  104. mimeType: 'text/html'
  105. )
  106. }
  107. // vim: et:ts=2:sw=2:ft=groovy