Jenkins xUnit 插件的控制参数

Control parameters for the Jenkins xUnit plugin

我有这个 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 的 运行 时。

由于您通常不想在已知的遗留测试中将构建标记为 failedunstable,因此您可以指定您希望 fail/skip 进行多少测试。

您有文档中解释的配置: 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 之间的区别是在将构建设置为 FAILED 或 UNSTABLE 之前允许失败多少次测试。

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