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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 = '10a5f89e-504b-11e8-945d-7fd7b29cc41c'
  30. localRepository = "../.archiva-master-repository"
  31. pipeline {
  32. agent {
  33. label "${LABEL}"
  34. }
  35. stages {
  36. stage('Checkout') {
  37. steps {
  38. script {
  39. echo "Info: Job-Name=${JOB_NAME}, Branch=${BRANCH_NAME}, Workspace=${PWD}"
  40. }
  41. checkout scm
  42. }
  43. post {
  44. failure {
  45. notifyBuild("Checkout failure")
  46. }
  47. }
  48. }
  49. stage('Test htmlunit') {
  50. steps {
  51. timeout(120) {
  52. withMaven(maven: buildMvn, jdk: buildJdk,
  53. mavenSettingsConfig: deploySettings,
  54. mavenLocalRepo: localRepository,
  55. options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true),
  56. findbugsPublisher(disabled: true), artifactsPublisher(disabled: true),
  57. invokerPublisher(disabled: true), jgivenPublisher(disabled: true),
  58. junitPublisher(disabled: true, ignoreAttachments: false),
  59. openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)]
  60. )
  61. {
  62. sh "chmod 755 ./src/ci/scripts/prepareWorkspace.sh"
  63. sh "./src/ci/scripts/prepareWorkspace.sh -d '.repository'"
  64. // Needs a lot of time to reload the repository files, try without cleanup
  65. // Not sure, but maybe
  66. // sh "rm -rf .repository"
  67. // Run test phase / ignore test failures
  68. // -B: Batch mode
  69. // -U: Force snapshot update
  70. // -e: Produce execution error messages
  71. // -fae: Fail at the end
  72. // -Dmaven.compiler.fork=true: Compile in a separate forked process
  73. // -Pci-server: Profile for CI-Server
  74. // -Pit-js: Run the selenium test
  75. 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"
  76. }
  77. }
  78. }
  79. post {
  80. always {
  81. junit testResults: '**/target/failsafe-reports/TEST-*.xml'
  82. }
  83. failure {
  84. notifyBuild("Failure in Htmlunit test stage")
  85. }
  86. }
  87. }
  88. // Uses a docker container that is started by script. Maybe we could use the docker functionality
  89. // of the jenkins pipeline in the future.
  90. stage('Test chrome') {
  91. steps {
  92. timeout(120) {
  93. withCredentials([[$class : 'UsernamePasswordMultiBinding', credentialsId: DOCKERHUB_CREDS,
  94. usernameVariable: 'DOCKER_HUB_USER', passwordVariable: 'DOCKER_HUB_PW']]) {
  95. withMaven(maven: buildMvn, jdk: buildJdk,
  96. mavenSettingsConfig: deploySettings,
  97. mavenLocalRepo: localRepository,
  98. options: [concordionPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true),
  99. findbugsPublisher(disabled: true), artifactsPublisher(disabled: true),
  100. invokerPublisher(disabled: true), jgivenPublisher(disabled: true),
  101. junitPublisher(disabled: true, ignoreAttachments: false),
  102. openTasksPublisher(disabled: true), pipelineGraphPublisher(disabled: true)]
  103. )
  104. {
  105. sh "chmod 755 ./src/ci/scripts/prepareWorkspace.sh"
  106. sh "./src/ci/scripts/prepareWorkspace.sh"
  107. sh "chmod 755 src/ci/scripts/container_webtest.sh"
  108. sh "src/ci/scripts/container_webtest.sh start"
  109. // Needs a lot of time to reload the repository files, try without cleanup
  110. // Not sure, but maybe
  111. // sh "rm -rf .repository"
  112. // Run test phase / ignore test failures
  113. // -B: Batch mode
  114. // -U: Force snapshot update
  115. // -e: Produce execution error messages
  116. // -fae: Fail at the end
  117. // -Pci-server: Profile for CI Server
  118. // -Pit-js: Runs the Selenium tests
  119. // -Pchrome: Activates the Selenium Chrome Test Agent
  120. 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"
  121. }
  122. }
  123. }
  124. }
  125. post {
  126. always {
  127. sh "src/ci/scripts/container_webtest.sh stop"
  128. junit testResults: '**/target/failsafe-reports/TEST-*.xml'
  129. }
  130. failure {
  131. notifyBuild("Failure in Chrome test stage")
  132. }
  133. }
  134. }
  135. }
  136. post {
  137. unstable {
  138. notifyBuild("Unstable Build")
  139. }
  140. success {
  141. script {
  142. def previousResult = currentBuild.previousBuild?.result
  143. if (previousResult && !currentBuild.resultIsWorseOrEqualTo(previousResult)) {
  144. notifyBuild("Fixed")
  145. }
  146. }
  147. cleanWs deleteDirs: true, notFailBuild: true, patterns: [[pattern: '.repository', type: 'EXCLUDE']]
  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