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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. buildJdk11 = 'JDK 11 (latest)'
  34. buildMvn = 'Maven 3.5.2'
  35. //localRepository = ".repository"
  36. localRepository = "../.maven_repositories/${env.EXECUTOR_NUMBER}"
  37. mavenOpts = '-Xms1g -Xmx2g -Djava.awt.headless=true'
  38. publishers = [artifactsPublisher(disabled: false),
  39. junitPublisher(disabled: false, ignoreAttachments: false),
  40. pipelineGraphPublisher(disabled: false),mavenLinkerPublisher(disabled: false)]
  41. INTEGRATION_PIPELINE = "Archiva-IntegrationTests-Gitbox"
  42. pipeline {
  43. agent {
  44. label "${LABEL}"
  45. }
  46. options {
  47. disableConcurrentBuilds()
  48. buildDiscarder(logRotator(numToKeepStr: '7', artifactNumToKeepStr: '5'))
  49. }
  50. parameters {
  51. booleanParam(name: 'PRECLEANUP', defaultValue: false, description: 'Clears the local maven repository before build.')
  52. }
  53. stages {
  54. stage('PreCleanup') {
  55. when {
  56. expression {
  57. params.PRECLEANUP
  58. }
  59. }
  60. steps {
  61. sh "rm -rf ${localRepository}"
  62. }
  63. }
  64. stage('BuildAndDeploy') {
  65. environment {
  66. ARCHIVA_USER_CONFIG_FILE = '/tmp/archiva-master-jdk-8-${env.JOB_NAME}.xml'
  67. }
  68. steps {
  69. timeout(120) {
  70. withMaven(maven: buildMvn, jdk: buildJdk,
  71. mavenLocalRepo: localRepository,
  72. publisherStrategy: 'EXPLICIT',
  73. mavenOpts: mavenOpts,
  74. options: publishers )
  75. {
  76. sh "chmod 755 ./src/ci/scripts/prepareWorkspace.sh"
  77. sh "./src/ci/scripts/prepareWorkspace.sh"
  78. // Needs a lot of time to reload the repository files, try without cleanup
  79. // Not sure, but maybe
  80. // sh "rm -rf .repository"
  81. // Run test phase / ignore test failures
  82. // -B: Batch mode
  83. // -U: Force snapshot update
  84. // -e: Produce execution error messages
  85. // -fae: Fail at the end
  86. // -Dmaven.compiler.fork=true: Do compile in a separate forked process
  87. // -Dmaven.test.failure.ignore=true: Do not stop, if some tests fail
  88. // -Pci-build: Profile for CI-Server
  89. sh "mvn clean deploy -B -U -e -fae -Dmaven.compiler.fork=true -Pci-build -T3"
  90. }
  91. }
  92. }
  93. post {
  94. always {
  95. sh "rm -f /tmp/archiva-master-jdk-8-${env.JOB_NAME}.xml"
  96. }
  97. failure {
  98. script{
  99. asfStandardBuild.notifyBuild("Failure in BuildAndDeploy stage")
  100. }
  101. }
  102. }
  103. }
  104. stage('Postbuild') {
  105. parallel {
  106. stage('IntegrationTest') {
  107. steps {
  108. build(job: "${INTEGRATION_PIPELINE}/archiva/${env.BRANCH_NAME}", propagate: false, quietPeriod: 5, wait: false)
  109. }
  110. }
  111. stage('JDK11') {
  112. environment {
  113. ARCHIVA_USER_CONFIG_FILE = '/tmp/archiva-master-jdk-11-${env.JOB_NAME}.xml'
  114. }
  115. steps {
  116. ws("${env.JOB_NAME}-JDK11") {
  117. checkout scm
  118. timeout(120) {
  119. withMaven(maven: buildMvn, jdk: buildJdk11,
  120. mavenLocalRepo: ".repository",
  121. publisherStrategy: 'EXPLICIT',
  122. mavenOpts: mavenOpts,
  123. options: publishers
  124. )
  125. {
  126. sh "mvn clean install -U -B -e -fae -Dmaven.compiler.fork=true -Pci-build -T3"
  127. }
  128. }
  129. }
  130. }
  131. post {
  132. always {
  133. sh "rm -f /tmp/archiva-master-jdk-11-${env.JOB_NAME}.xml"
  134. }
  135. success {
  136. cleanWs()
  137. }
  138. }
  139. }
  140. }
  141. }
  142. }
  143. post {
  144. unstable {
  145. script {
  146. asfStandardBuild.notifyBuild("Unstable Build")
  147. }
  148. }
  149. success {
  150. script {
  151. def previousResult = currentBuild.previousBuild?.result
  152. if (previousResult && !currentBuild.resultIsWorseOrEqualTo(previousResult)) {
  153. asfStandardBuild.notifyBuild("Fixed")
  154. }
  155. }
  156. }
  157. }
  158. }
  159. // vim: et:ts=4:sw=4:ft=groovy