如何在 UnitTest++ 1.4 中使用 jenkins 管道脚本

How to use jenkins pipeline script with UnitTest++ 1.4

我有一些在 jenkins 上构建的 C++ 代码。我 运行 UnitTest++ 1.4 来测试 C++ 代码,这会生成一些 TestResults*.xml.

只要我使用 Web 前端配置 jenkins 构建作业,这就很好用:

对于新的构建作业,我必须改用 jenkins 管道插件,因此我必须编写一个 Jenkinsfile。为了评估我的TestResults*.xml,我只找到了两个选择:

junit 'TestResults*.xml'
step([$class: 'JUnitResultArchiver', testResults: 'TestResults*.xml'])

但其中 none 有效。似乎 junit xml 格式与 UnitTest++ 1.4 不同。

有谁知道正确使用 UnitTest++ 1.4 测试结果 xml 输出需要哪个 Jenkinsfile 语句?

解决方案是,如果使用 JUnit 插件,则使用 xUnit 插件。像这样:

step([
    $class: 'XUnitBuilder', testTimeMargin: '3000', thresholdMode: 1,
    thresholds: [
        [$class: 'FailedThreshold', failureNewThreshold: '', failureThreshold: '0', unstableNewThreshold: '', unstableThreshold: ''],
        [$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']
    ],
    tools: [[
        $class: 'UnitTestJunitHudsonTestType',
        deleteOutputFiles: true,
        failIfNotNew: true,
        pattern: 'result.xml',
        skipNoTestFiles: false,
        stopProcessingIfError: true
    ]]
])