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

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