如何使用 Jenkins 管道和 xUnit 插件发布 Boost 单元测试

How do I publish Boost unit tests with Jenkins pipeline and xUnit plugin

我正在将旧的 Jenkins 构建迁移到声明性管道。我们使用 xUnit 插件发布单元测试,对于 JUnit,以下工作正常:

step([$class: 'XUnitBuilder',
      thresholds: [[$class: 'FailedThreshold', unstableThreshold: '1']],
      tools: [[$class: 'JUnitType', pattern: '**/surefire-reports/*.xml'],
              [$class: 'JUnitType', pattern: '**/generatedJUnitFiles/JUnit/*.xml'],]
     ])

我的问题是我不知道如何发布我们的增强测试。是否有类似于 JUnitTypeBoostType,或者是否还不支持增强测试?

有一个 class BoostTest in Jenkins' xUnit Plugin.

答案竟然是BoostTestJunitHudsonTestType。这是代码:

step([$class: 'XUnitBuilder',
            thresholds: [[$class: 'FailedThreshold', unstableThreshold: '1']],
            tools: [[$class: 'JUnitType', pattern: '**/surefire-reports/*.xml'],
                    [$class: 'JUnitType', pattern: '**/generatedJUnitFiles/JUnit/*.xml'],
                    [$class: 'BoostTestJunitHudsonTestType', pattern: '**/*_results.xml'],
                     ]])

new xunit Plugin syntax 更轻巧,更易读:

pipeline {
    agent any
    stages {
        stage('Test'){
            steps {
                sh "run_tests.bash"
            }
        }
    }
    post {
        always{
            xunit (
                thresholds: [ skipped(failureThreshold: '0'), failed(failureThreshold: '0') ],
                tools: [
                    JUnit(pattern: '**/surefire-reports/*.xml'),
                    JUnit(pattern: '**/generatedJUnitFiles/JUnit/*.xml'),
                    BoostTest(pattern: '**/*_results.xml')]
            )
        }
    }
 }