I have the following 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.
}
}
In that final stage, "Combine and Publish Coverage" is it possible to combine all of the xml files created by gcovr?
Has anyone solved the problem of testing in parallel and combining coverage results in another way entirely?
The following solution isn't as elegant as I'd like, but the best I can come up with.
Use lcov
instead of gcovr
to initially generate the coverage reports. This creates .info
files which lcov
is capable of combining down to a single .info
file.
Unstash all .info
files from previous stages, then use lcov -a
to combine them into a single .info
file. (Reference)
Next, use the lcov-to-cobertura
converter to convert this .info
file into an xml file which can be reported to SonarQube.