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

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