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-itest 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. * UI-Test Build file for Jenkins Multibranch pipeline.
  21. *
  22. * The pipeline runs only the UI tests.
  23. *
  24. */
  25. LABEL = 'ubuntu'
  26. buildJdk = 'jdk_1.8_latest'
  27. buildMvn = 'maven_3.5.4'
  28. deploySettings = 'archiva-uid-jenkins'
  29. DOCKERHUB_CREDS = 'c725478f-9125-460a-900f-1da562e51026'
  30. //localRepository = ".repository"
  31. localRepository = "../.maven_repositories/${env.EXECUTOR_NUMBER}"
  32. pipeline {
  33. agent {
  34. label "${LABEL}"
  35. }
  36. options {
  37. disableConcurrentBuilds()
  38. durabilityHint('PERFORMANCE_OPTIMIZED')
  39. buildDiscarder(logRotator(numToKeepStr: '5', artifactNumToKeepStr: '3'))
  40. }
  41. stages {
  42. stage('Checkout') {
  43. steps {
  44. script {
  45. echo "Info: Job-Name=${JOB_NAME}, Branch=${BRANCH_NAME}, Workspace=${PWD}"
  46. }
  47. checkout scm
  48. }
  49. post {
  50. failure {
  51. notifyBuild("Checkout failure")
  52. }
  53. }
  54. }
  55. stage('Test htmlunit') {
  56. when {
  57. not {
  58. triggeredBy 'UpstreamCause'
  59. }
  60. }
  61. steps {
  62. timeout(120) {
  63. withMaven(maven: buildMvn, jdk: buildJdk,
  64. mavenSettingsConfig: deploySettings,
  65. mavenLocalRepo: localRepository,
  66. publisherStrategy: 'EXPLICIT',
  67. options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true),
  68. findbugsPublisher(disabled: true), artifactsPublisher(disabled: true),
  69. invokerPublisher(disabled: true), jgivenPublisher(disabled: true),
  70. junitPublisher(disabled: true, ignoreAttachments: false),
  71. openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)]
  72. )
  73. {
  74. sh "chmod 755 ./src/ci/scripts/prepareWorkspace.sh"
  75. sh "./src/ci/scripts/prepareWorkspace.sh -d '.repository'"
  76. // Needs a lot of time to reload the repository files, try without cleanup
  77. // Not sure, but maybe
  78. // sh "rm -rf .repository"
  79. // Run test phase / ignore test failures
  80. // -B: Batch mode
  81. // -U: Force snapshot update
  82. // -e: Produce execution error messages
  83. // -fae: Fail at the end
  84. // -Dmaven.compiler.fork=true: Compile in a separate forked process
  85. // -Pci-server: Profile for CI-Server
  86. // -Pit-js: Run the selenium test
  87. sh "mvn clean verify -B -V -U -e -fae -DmaxWaitTimeInMs=2000 -Pci-server -Pit-js -DtrimStackTrace=false -Djava.io.tmpdir=.tmp -pl :archiva-webapp-test"
  88. }
  89. }
  90. }
  91. post {
  92. always {
  93. junit testResults: '**/target/failsafe-reports/TEST-*.xml'
  94. }
  95. failure {
  96. notifyBuild("Failure in Htmlunit test stage")
  97. }
  98. }
  99. }
  100. // Uses a docker container that is started by script. Maybe we could use the docker functionality
  101. // of the jenkins pipeline in the future.
  102. stage('Test chrome') {
  103. when {
  104. not {
  105. triggeredBy 'UpstreamCause'
  106. }
  107. }
  108. steps {
  109. timeout(120) {
  110. withCredentials([[$class : 'UsernamePasswordMultiBinding', credentialsId: DOCKERHUB_CREDS,
  111. usernameVariable: 'DOCKER_HUB_USER', passwordVariable: 'DOCKER_HUB_PW']]) {
  112. withMaven(maven: buildMvn, jdk: buildJdk,
  113. mavenSettingsConfig: deploySettings,
  114. mavenLocalRepo: localRepository,
  115. publisherStrategy: 'EXPLICIT',
  116. options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true),
  117. findbugsPublisher(disabled: true), artifactsPublisher(disabled: true),
  118. invokerPublisher(disabled: true), jgivenPublisher(disabled: true),
  119. junitPublisher(disabled: true, ignoreAttachments: false),
  120. openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)]
  121. )
  122. {
  123. sh "chmod 755 ./src/ci/scripts/prepareWorkspace.sh"
  124. sh "./src/ci/scripts/prepareWorkspace.sh"
  125. sh "chmod 755 src/ci/scripts/container_webtest.sh"
  126. sh "src/ci/scripts/container_webtest.sh start"
  127. // Needs a lot of time to reload the repository files, try without cleanup
  128. // Not sure, but maybe
  129. // sh "rm -rf .repository"
  130. // Run test phase / ignore test failures
  131. // -B: Batch mode
  132. // -U: Force snapshot update
  133. // -e: Produce execution error messages
  134. // -fae: Fail at the end
  135. // -Pci-server: Profile for CI Server
  136. // -Pit-js: Runs the Selenium tests
  137. // -Pchrome: Activates the Selenium Chrome Test Agent
  138. sh "mvn clean verify -B -V -e -fae -DmaxWaitTimeInMs=2000 -DseleniumRemote=true -Pci-server -Pit-js -Pchrome -pl :archiva-webapp-test -DtrimStackTrace=false"
  139. }
  140. }
  141. }
  142. }
  143. post {
  144. always {
  145. sh "src/ci/scripts/container_webtest.sh stop"
  146. junit testResults: '**/target/failsafe-reports/TEST-*.xml'
  147. }
  148. failure {
  149. notifyBuild("Failure in Chrome test stage")
  150. }
  151. }
  152. }
  153. }
  154. post {
  155. unstable {
  156. notifyBuild("Unstable Build")
  157. }
  158. success {
  159. script {
  160. def previousResult = currentBuild.previousBuild?.result
  161. if (previousResult && !currentBuild.resultIsWorseOrEqualTo(previousResult)) {
  162. notifyBuild("Fixed")
  163. }
  164. }
  165. cleanWs deleteDirs: true, notFailBuild: true, patterns: [[pattern: '.repository', type: 'EXCLUDE']]
  166. }
  167. }
  168. }
  169. // Send a notification about the build status
  170. def notifyBuild(String buildStatus) {
  171. // default the value
  172. buildStatus = buildStatus ?: "UNKNOWN"
  173. def email = "notifications@archiva.apache.org"
  174. def summary = "${env.JOB_NAME}#${env.BUILD_NUMBER} - ${buildStatus} - ${currentBuild?.currentResult}"
  175. def detail = """<h4>Job: <a href='${env.JOB_URL}'>${env.JOB_NAME}</a> [#${env.BUILD_NUMBER}]</h4>
  176. <p><b>${buildStatus}</b></p>
  177. <table>
  178. <tr><td>Build</td><td><a href='${env.BUILD_URL}'>${env.BUILD_URL}</a></td><tr>
  179. <tr><td>Console</td><td><a href='${env.BUILD_URL}console'>${env.BUILD_URL}console</a></td><tr>
  180. <tr><td>Test Report</td><td><a href='${env.BUILD_URL}testReport/'>${env.BUILD_URL}testReport/</a></td><tr>
  181. </table>
  182. """
  183. emailext(
  184. to: email,
  185. subject: summary,
  186. body: detail,
  187. mimeType: 'text/html'
  188. )
  189. }
  190. // vim: et:ts=4:sw=4:ft=groovy