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 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. /**
  20. * Main build file for Jenkins Multibranch pipeline.
  21. *
  22. * The pipeline builds, runs the test and deploys to the archiva snapshot repository.
  23. *
  24. * Uses one stage for build and deploy to avoid running it multiple times.
  25. * The settings for deployment with the credentials must be provided by a MavenSettingsProvider.
  26. *
  27. * Only the war and zip artifacts are archived in the jenkins build archive.
  28. */
  29. LABEL = 'ubuntu'
  30. buildJdk = 'JDK 1.8 (latest)'
  31. buildJdk9 = 'JDK 1.9 (latest)'
  32. buildJdk10 = 'JDK 10 (latest)'
  33. buildMvn = 'Maven 3.5.2'
  34. deploySettings = 'DefaultMavenSettingsProvider.1331204114925'
  35. INTEGRATION_PIPELINE = "Archiva-IntegrationTests-Gitbox"
  36. pipeline {
  37. agent {
  38. label "${LABEL}"
  39. }
  40. stages {
  41. stage('BuildAndDeploy') {
  42. steps {
  43. timeout(120) {
  44. withMaven(maven: buildMvn, jdk: buildJdk,
  45. mavenLocalRepo: ".repository",
  46. options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true),
  47. findbugsPublisher(disabled: true), artifactsPublisher(disabled: true),
  48. invokerPublisher(disabled: true), jgivenPublisher(disabled: true),
  49. junitPublisher(disabled: true, ignoreAttachments: false),
  50. openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)]
  51. )
  52. {
  53. sh "chmod 755 ./src/ci/scripts/prepareWorkspace.sh"
  54. sh "./src/ci/scripts/prepareWorkspace.sh"
  55. // Needs a lot of time to reload the repository files, try without cleanup
  56. // Not sure, but maybe
  57. // sh "rm -rf .repository"
  58. // Run test phase / ignore test failures
  59. // -B: Batch mode
  60. // -U: Force snapshot update
  61. // -e: Produce execution error messages
  62. // -fae: Fail at the end
  63. // -Dmaven.compiler.fork=true: Do compile in a separate forked process
  64. // -Dmaven.test.failure.ignore=true: Do not stop, if some tests fail
  65. // -Pci-build: Profile for CI-Server
  66. sh "mvn clean deploy -B -U -e -fae -T2 -Dmaven.compiler.fork=true -Pci-build"
  67. }
  68. }
  69. }
  70. post {
  71. always {
  72. junit testResults: '**/target/surefire-reports/TEST-*.xml'
  73. }
  74. success {
  75. archiveArtifacts '**/target/*.war,**/target/*-bin.zip'
  76. }
  77. failure {
  78. notifyBuild("Failure in BuildAndDeploy stage")
  79. }
  80. }
  81. }
  82. stage('IntegrationTest') {
  83. steps {
  84. build(job: "${INTEGRATION_PIPELINE}/archiva/${env.BRANCH_NAME}", propagate: false, quietPeriod: 10)
  85. }
  86. }
  87. stage('JDKs') {
  88. parallel {
  89. stage('JDK9') {
  90. steps {
  91. ws("${env.JOB_NAME}-JDK9") {
  92. checkout scm
  93. timeout(120) {
  94. withMaven(maven: buildMvn, jdk: buildJdk9,
  95. mavenSettingsConfig: deploySettings,
  96. mavenLocalRepo: ".repository",
  97. options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true),
  98. findbugsPublisher(disabled: true), artifactsPublisher(disabled: true),
  99. invokerPublisher(disabled: true), jgivenPublisher(disabled: true),
  100. junitPublisher(disabled: true, ignoreAttachments: false),
  101. openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)]
  102. )
  103. {
  104. sh "mvn clean install -B -U -e -fae -T2 -Dmaven.compiler.fork=true -Pci-build"
  105. }
  106. }
  107. }
  108. }
  109. }
  110. stage('JDK10') {
  111. steps {
  112. ws("${env.JOB_NAME}-JDK10") {
  113. checkout scm
  114. timeout(120) {
  115. withMaven(maven: buildMvn, jdk: buildJdk10,
  116. mavenSettingsConfig: deploySettings,
  117. mavenLocalRepo: ".repository",
  118. options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true),
  119. findbugsPublisher(disabled: true), artifactsPublisher(disabled: true),
  120. invokerPublisher(disabled: true), jgivenPublisher(disabled: true),
  121. junitPublisher(disabled: true, ignoreAttachments: false),
  122. openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)]
  123. )
  124. {
  125. sh "mvn clean install -B -U -e -fae -T2 -Dmaven.compiler.fork=true -Pci-build"
  126. }
  127. }
  128. }
  129. }
  130. }
  131. }
  132. }
  133. }
  134. post {
  135. unstable {
  136. notifyBuild("Unstable Build")
  137. }
  138. success {
  139. script {
  140. def previousResult = currentBuild.previousBuild?.result
  141. if (previousResult && !currentBuild.resultIsWorseOrEqualTo(previousResult)) {
  142. notifyBuild("Fixed")
  143. }
  144. }
  145. }
  146. always {
  147. cleanWs()
  148. }
  149. }
  150. }
  151. // Send a notification about the build status
  152. def notifyBuild(String buildStatus) {
  153. // default the value
  154. buildStatus = buildStatus ?: "UNKNOWN"
  155. def email = "notifications@archiva.apache.org"
  156. def summary = "${env.JOB_NAME}#${env.BUILD_NUMBER} - ${buildStatus} - ${currentBuild?.currentResult}"
  157. def detail = """<h4>Job: <a href='${env.JOB_URL}'>${env.JOB_NAME}</a> [#${env.BUILD_NUMBER}]</h4>
  158. <p><b>${buildStatus}</b></p>
  159. <table>
  160. <tr><td>Build</td><td><a href='${env.BUILD_URL}'>${env.BUILD_URL}</a></td><tr>
  161. <tr><td>Console</td><td><a href='${env.BUILD_URL}console'>${env.BUILD_URL}console</a></td><tr>
  162. <tr><td>Test Report</td><td><a href='${env.BUILD_URL}testReport/'>${env.BUILD_URL}testReport/</a></td><tr>
  163. </table>
  164. """
  165. emailext(
  166. to: email,
  167. subject: summary,
  168. body: detail,
  169. mimeType: 'text/html'
  170. )
  171. }
  172. // vim: et:ts=4:sw=4:ft=groovy