jenkins - Jenkins xUnit 插件的控制参数

标签 jenkins jenkins-plugins jenkins-pipeline xunit

我有这个 Jenkinsfile 并且我使用了 xUnit 插件。我想了解此文件中使用的关键字:

node{
  stage ('Checkout')
  {
    checkout scm
  }
  stage ('Build')
  {
    try {
        sh '''
           mvn clean -B org.jacoco:jacoco-maven-plugin:prepare-agent install
        '''
      } catch (err) {
        // do nothing
      } finally {
        //step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
       step([$class: 'XUnitBuilder', testTimeMargin: '3000', thresholdMode: 1,
    thresholds: [
        [$class: 'FailedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '1'],
        [$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']],
    tools: [
        [$class: 'JUnitType', deleteOutputFiles: false, failIfNotNew: false, pattern: '**/target/surefire-reports/TEST-*.xml', skipNoTestFiles: true, stopProcessingIfError: false]]
    ])
    }
  }
}

SkippedThreshold 是什么意思? failureNewThresholdfailureThreshold 以及 unstableNewThresholdunstableThreshold 之间有什么区别?

感谢您帮助我理解这一点,我找不到明确的文档。希望这会帮助其他人。

最佳答案

当您第一次配置 xUnit 时,对于一个现有项目,您不希望每次测试都成功。其中一些可能需要一些调整,特别是从 jenkins slave 运行时。

因为您通常不希望在已知的遗留测试中将构建标记为失败不稳定,您可以指定您希望失败/跳过多少测试.

您有文档中解释的配置: https://media.readthedocs.org/pdf/jenkins-job-builder/latest/jenkins-job-builder.pdf

Parameters:

thresholdmode ( str ) – Whether thresholds represents an absolute number of tests or a percentage. Either ‘number’ or ‘percent’. (default ‘number’)

thresholds ( list ) – Thresholds for both ‘failed’ and ‘skipped’ tests.

  • threshold ( dict ) threshold values to set, where missing, xUnit should default to an internal value of 0. Each test threshold should contain the following:

    • unstable (int)

    • unstablenew (int)

    • failure (int)

    • failurenew (int)

failureThresholdunstableThreshold 之间的区别在于,在将build设置为 FAILED 或 UNSTABLE 之前,您允许失败多少次测试。

关键字“new”允许您设置是否授权添加新的失败测试,​​以及有多少。

关于jenkins - Jenkins xUnit 插件的控制参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50247967/

相关文章:

Jenkins 配置作为代码插件与 Pipeline

java - 如何在 Groovy Jenkins 管道中使用全局外部 Java 库中的方法?

amazon-web-services - 云信息 : Outputs - Can you return a value from a file

maven - 如何根据 maven pom 版本运行 github-action 条件?

selenium - 如何并行执行多个测试套件?

java - 我无法在 Jenkins 中构建工作,,,即使我已经给出了 github 的路径

maven - QTP 到 Jenkins 集成帮助需要 CI

java - SMTP 和 startssl jenkins 异常

amazon-web-services - Jenkins AWS 凭证插件不起作用

tomcat - 如何使用 Jenkins 管道将 war 部署到tomcat?