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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true),
  67. findbugsPublisher(disabled: true), artifactsPublisher(disabled: true),
  68. invokerPublisher(disabled: true), jgivenPublisher(disabled: true),
  69. junitPublisher(disabled: true, ignoreAttachments: false),
  70. openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)]
  71. )
  72. {
  73. sh "chmod 755 ./src/ci/scripts/prepareWorkspace.sh"
  74. sh "./src/ci/scripts/prepareWorkspace.sh -d '.repository'"
  75. // Needs a lot of time to reload the repository files, try without cleanup
  76. // Not sure, but maybe
  77. // sh "rm -rf .repository"
  78. // Run test phase / ignore test failures
  79. // -B: Batch mode
  80. // -U: Force snapshot update
  81. // -e: Produce execution error messages
  82. // -fae: Fail at the end
  83. // -Dmaven.compiler.fork=true: Compile in a separate forked process
  84. // -Pci-server: Profile for CI-Server
  85. // -Pit-js: Run the selenium test
  86. sh "mvn clean verify -B -V -U -e -fae -Dmaven.compiler.fork=true -DmaxWaitTimeInMs=2000 -Pci-server -Pit-js -DtrimStackTrace=false -Djava.io.tmpdir=.tmp -pl :archiva-webapp-test"
  87. }
  88. }
  89. }
  90. post {
  91. always {
  92. junit testResults: '**/target/failsafe-reports/TEST-*.xml'
  93. }
  94. failure {
  95. notifyBuild("Failure in Htmlunit test stage")
  96. }
  97. }
  98. }
  99. // Uses a docker container that is started by script. Maybe we could use the docker functionality
  100. // of the jenkins pipeline in the future.
  101. stage('Test chrome') {
  102. when {
  103. not {
  104. triggeredBy 'UpstreamCause'
  105. }
  106. }
  107. steps {
  108. timeout(120) {
  109. withCredentials([[$class : 'UsernamePasswordMultiBinding', credentialsId: DOCKERHUB_CREDS,
  110. usernameVariable: 'DOCKER_HUB_USER', passwordVariable: 'DOCKER_HUB_PW']]) {
  111. withMaven(maven: buildMvn, jdk: buildJdk,
  112. mavenSettingsConfig: deploySettings,
  113. mavenLocalRepo: localRepository,
  114. options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true),
  115. findbugsPublisher(disabled: true), artifactsPublisher(disabled: true),
  116. invokerPublisher(disabled: true), jgivenPublisher(disabled: true),
  117. junitPublisher(disabled: true, ignoreAttachments: false),
  118. openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)]
  119. )
  120. {
  121. sh "chmod 755 ./src/ci/scripts/prepareWorkspace.sh"
  122. sh "./src/ci/scripts/prepareWorkspace.sh"
  123. sh "chmod 755 src/ci/scripts/container_webtest.sh"
  124. sh "src/ci/scripts/container_webtest.sh start"
  125. // Needs a lot of time to reload the repository files, try without cleanup
  126. // Not sure, but maybe
  127. // sh "rm -rf .repository"
  128. // Run test phase / ignore test failures
  129. // -B: Batch mode
  130. // -U: Force snapshot update
  131. // -e: Produce execution error messages
  132. // -fae: Fail at the end
  133. // -Pci-server: Profile for CI Server
  134. // -Pit-js: Runs the Selenium tests
  135. // -Pchrome: Activates the Selenium Chrome Test Agent
  136. sh "mvn clean verify -B -V -e -fae -Dmaven.compiler.fork=true -DmaxWaitTimeInMs=2000 -DseleniumRemote=true -Pci-server -Pit-js -Pchrome -pl :archiva-webapp-test -DtrimStackTrace=false"
  137. }
  138. }
  139. }
  140. }
  141. post {
  142. always {
  143. sh "src/ci/scripts/container_webtest.sh stop"
  144. junit testResults: '**/target/failsafe-reports/TEST-*.xml'
  145. }
  146. failure {
  147. notifyBuild("Failure in Chrome test stage")
  148. }
  149. }
  150. }
  151. }
  152. post {
  153. unstable {
  154. notifyBuild("Unstable Build")
  155. }
  156. success {
  157. script {
  158. def previousResult = currentBuild.previousBuild?.result
  159. if (previousResult && !currentBuild.resultIsWorseOrEqualTo(previousResult)) {
  160. notifyBuild("Fixed")
  161. }
  162. }
  163. cleanWs deleteDirs: true, notFailBuild: true, patterns: [[pattern: '.repository', type: 'EXCLUDE']]
  164. }
  165. }
  166. }
  167. // Send a notification about the build status
  168. def notifyBuild(String buildStatus) {
  169. // default the value
  170. buildStatus = buildStatus ?: "UNKNOWN"
  171. def email = "notifications@archiva.apache.org"
  172. def summary = "${env.JOB_NAME}#${env.BUILD_NUMBER} - ${buildStatus} - ${currentBuild?.currentResult}"
  173. def detail = """<h4>Job: <a href='${env.JOB_URL}'>${env.JOB_NAME}</a> [#${env.BUILD_NUMBER}]</h4>
  174. <p><b>${buildStatus}</b></p>
  175. <table>
  176. <tr><td>Build</td><td><a href='${env.BUILD_URL}'>${env.BUILD_URL}</a></td><tr>
  177. <tr><td>Console</td><td><a href='${env.BUILD_URL}console'>${env.BUILD_URL}console</a></td><tr>
  178. <tr><td>Test Report</td><td><a href='${env.BUILD_URL}testReport/'>${env.BUILD_URL}testReport/</a></td><tr>
  179. </table>
  180. """
  181. emailext(
  182. to: email,
  183. subject: summary,
  184. body: detail,
  185. mimeType: 'text/html'
  186. )
  187. }
  188. // vim: et:ts=4:sw=4:ft=groovy