在Jenkins管道中合并并行阶段的C ++覆盖范围结果

时间:2018-12-14 13:50:44

标签: jenkins sonarqube gcov jenkins-declarative-pipeline

我有以下Jenkinsfile:

pipeline{
   stages
   {
      stage ("Compile Everything") {/**/} // Code coverage flags turned on
                                          // Stashes compiled test binaries. 
      stage ("Parallel Tests"){
         parallel{
            stage ("Run Tests A-L") {/**/} // These stages unstash and run groups of tests,
            stage ("Run Tests L-Z") {/**/} // causing coverage files to be created.
                                           // I analyze those coverage files via
                                           // gcovr and stash the results as xml.
         }
      }

      stage ("Combine and Publish Coverage") {/**/} // Here I can unstash all of the xml
                                                    // code coverage files, but don't know
                                                    // how to combine them.
   }
}

在最后一个阶段,“合并和发布Coverage”是否可以合并gcovr创建的所有xml文件?

有人解决了并行测试并以另一种方式完全合并覆盖结果的问题吗?

1 个答案:

答案 0 :(得分:0)

以下解决方案并不像我想要的那样优雅,但是我能提供的最好的解决方案。

使用lcov代替gcovr最初生成覆盖率报告。这将创建.info个文件,其中lcov可以合并为单个.info文件。

解压缩前阶段的所有.info文件,然后使用lcov -a将它们组合成单个.info文件。 (Reference

接下来,使用lcov-to-cobertura转换器将此.info文件转换为可以报告给SonarQube的xml文件。