Merging test coverage and test results from multiple Jenkins jobs Merging test coverage and test results from multiple Jenkins jobs jenkins jenkins

Merging test coverage and test results from multiple Jenkins jobs


Faced similar issue, tweaked jacoco maven plugin config to merge jacoco results. Basically merged jacoco-unit.exec and jacoco-it.exec into one binary and published that merged result on Jenkins via pipeline step.

pom.xml:

            <plugin>                    <inherited>false</inherited>                    <groupId>org.jacoco</groupId>                    <artifactId>jacoco-maven-plugin</artifactId>                    <version>${jacoco.agent.version}</version>                    <executions>                        <execution>                            <id>merge-results</id>                            <phase>post-integration-test</phase>                            <goals>                                <goal>merge</goal>                            </goals>                            <configuration>                                <fileSets>                                    <fileSet>                                        <directory>${project.parent.build.directory}</directory>                                        <includes>                                            <include>jacoco-*.exec</include>                                        </includes>                                    </fileSet>                                </fileSets>                                <destFile>${project.parent.build.directory}/jacoco.exec</destFile>                            </configuration>                        </execution>                    </executions>                </plugin>

Jenkinsfile:

            echo 'Publish Jacoco trend'            step($class: 'JacocoPublisher',                    execPattern: '**/jacoco.exec',                    classPattern: '**/classes',                    sourcePattern: '**/src/main/java',            )

However you still have to fetch jacoco binaries from several Jenkins builds by another build step or specify their locations explicitly.