Jenkins XUnitPublisher插件不会使构建失败

时间:2019-07-01 16:24:50

标签: jenkins grails junit xunit

我已经将我的jenkins管道配置为使用XUnitPublisher来验证结果并在任何测试都标记为失败的情况下标记构建。我可以看到测试后对结果进行了分析,但是构建未标记为失败,

[Pipeline] step
16:41:43 INFO: Starting to record.
16:41:43 INFO: Processing JUnit
16:41:44 INFO: Check 'Failed Tests' threshold.
16:41:44 INFO: The total number of tests for the threshold 'Failed Tests' exceeds the specified "failure threshold" value.
16:41:44 INFO: Setting the build status to FAILURE
16:41:44 INFO: Stopping recording.
[Pipeline] }
INFO: [JUnit] - 14 test report file(s) were found with the pattern 'serenity/target/site/serenity/SERENITY-JUNIT*.xml' relative to '/home/jenkins/workspace/Deployment' for the testing framework 'JUnit'.
[Pipeline] // node
[Pipeline] }
16:41:44 Lock released on resource [TESTS-DEV]
[Pipeline] // lock
[Pipeline] }
[Pipeline] // stage
[Pipeline] milestone
16:41:45 Trying to pass milestone 8000
[Pipeline] stage
[Pipeline] { (Approve to qa)
[Pipeline] timeout
16:41:46 Timeout set to expire in 5 days 0 hr
[Pipeline] {
[Pipeline] input
16:41:46 Proceed into qa?
16:41:46 Proceed or Abort
[Pipeline] }

我的管道脚本是

stage ('Testing in dev') {
    lock(resource: "TESTS-DEV", inversePrecedence: true){
       node('test-slave') {
    try {
        sh "mvn clean verify -f serenity/pom.xml '-DstoryNames=*/API/*/*.story' -Dmetafilter=+cms -Denvrun=dev -Dmockuser=true -Denv=dev -Dtestrunid=00001 -DproxyHost='' -DproxyPort='' -Dhttp.nonProxyHosts= "
    } catch (error) {
        mail(to: "${MAIL_WSU_DEVELOPERS_CSV},${MAIL_WSU_DEVOPS_CSV},${MAIL_WSU_TESTERS_CSV}", subject: "Job '${JOB_NAME}' (${BUILD_NUMBER}) Build has failed", body: "Please go to ${BUILD_URL}.");
        currentBuild.result = 'UNSTABLE'
        throw(error)
  } finally {
    publishHTML(target: [allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'serenity/target/site/serenity', reportFiles: 'index.html', reportName: "API Test Report on dev"])
    step([$class: 'XUnitPublisher', testTimeMargin: '3000', thresholdMode: 1, thresholds: [[$class: 'FailedThreshold', failureNewThreshold: '0', failureThreshold: '0', unstableNewThreshold: '0', unstableThreshold: '0'], [$class: 'SkippedThreshold', failureNewThreshold: '0', failureThreshold: '0', unstableNewThreshold: '0', unstableThreshold: '0']], tools: [[$class: 'JUnitType', deleteOutputFiles: true, failIfNotNew: true, pattern: 'serenity/target/site/serenity/SERENITY-JUNIT*.xml', skipNoTestFiles: true, stopProcessingIfError: true]]])
  }

  if (currentBuild.result == "UNSTABLE" ) {
mail (to: "${env.MAIL_WSU_DEVELOPERS_CSV},${env.MAIL_WSU_DEVOPS_CSV},${env.MAIL_WSU_TESTERS_CSV}",
     subject: "Job '${env.JOB_NAME}' (${env.BUILD_NUMBER}) is unstable",
    body: "Please go to ${env.BUILD_URL}.");
 currentBuild.result = "UNSTABLE"
 error()
   }
   if (currentBuild.result == "FAILURE" ) {
     mail (to: "${env.MAIL_WSU_DEVELOPERS_CSV},${env.MAIL_WSU_DEVOPS_CSV},${env.MAIL_WSU_TESTERS_CSV}",
     subject: "Job '${env.JOB_NAME}' (${env.BUILD_NUMBER}) has failed",
    body: "Please go to ${env.BUILD_URL}.");
currentBuild.result = "FAILURE"
error()
   }


   }
    }
   }

0 个答案:

没有答案