【发布时间】:2017-01-02 08:53:58
【问题描述】:
我正在自动化 dot net core build
鉴于我的 Jenkins 文件中的以下 sn-p,我为我拥有的每个测试项目生成一个 XML 文件。在接下来的步骤中,我想处理这些 XML 文件。
Jenkins 提供了两种选择。我很困惑使用哪个选项。我使用“过程”还是“发布”。两者都给出了相同的阈值选项,两者似乎都做同样的事情。他们都将构建标记为 FAILED,他们都向 Jenkins 提供了测试报告。这是遗产吗?或者它们是完全不同的步骤,有自己的目的?
顺便说一句,这个 FAILURE 检查并抛出错误是阻止 Jenkins 继续构建的唯一方法吗?当构建标记为 FAILED 以继续其余步骤时,这似乎有点奇怪。如果我想继续,我也可以将 stopProcessingIfError 设置为 false,还是我错过了重点?
stage('Test') {
def testScript = ""
def testProjects = findFiles(glob: 'test/**/project.json')
if (!fileExists('reports/xml')) {
if (!fileExists('reports')) {
sh "mkdir reports"
}
sh "mkdir reports/xml"
}
for(prj in testProjects) {
println "Test project located, running tests: " + prj.path
def matcher = prj.path =~ 'test\\/(.+)\\/project.json'
testScript += "dotnet test --no-build '${prj.path}' -xml 'reports/xml/${matcher[0][1]}.Results.xml' || true\n"
}
sh testScript
step([
$class: 'XUnitBuilder',
thresholdMode: 1,
thresholds: [[$class: 'FailedThreshold', failureThreshold: '1']],
tools: [[
$class: 'XUnitDotNetTestType',
deleteOutputFiles: true,
failIfNotNew: true,
pattern: 'reports/xml/*.Results.xml',
skipNoTestFiles: false,
stopProcessingIfError: true
]]
])
if (currentBuild.result.equals("FAILURE")) {
throw "Test results did not pass thresholds"
}
}
【问题讨论】:
标签: .net jenkins asp.net-core continuous-integration