我有这个 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
是什么意思?
failureNewThreshold
和 failureThreshold
以及 unstableNewThreshold
和 unstableThreshold
之间有什么区别?
感谢您帮助我理解这一点,我找不到明确的文档。希望这会帮助其他人。
最佳答案
当您第一次配置 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)
failureThreshold
和 unstableThreshold
之间的区别在于,在将build设置为 FAILED 或 UNSTABLE 之前,您允许失败多少次测试。
关键字“new”允许您设置是否授权添加新的失败测试,以及有多少。
关于jenkins - Jenkins xUnit 插件的控制参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50247967/