Best way to report Jacoco data to sonarqube from jenkins(Unit test) and remote dockerhost(Integration tests)

sonarqube version- 6.7.6

possibilities of integrating jenkins, sonarqube, jacoco

  1. We have jenkins running on VM A and and generating jacocoA.exec file for unit tests and for intergration test jacocoB.exec file getting generated from our app runs on remote docker host. One way is point sonarqube to that files jacocoA.exec and jacocoB.exec files and it should work?

2)Can someone confirm jacoco.exec file is the only way one can report jacoco data to sonaqube ?

3)The other thing we want to know is jacoco has other forms of reporting exec data other than writing to a file (https://www.jacoco.org/jacoco/trunk/doc/agent.html) It supportsTCP Socket server or TCP Socket Client. Does sonarqube supports any of such types either TCP Socket server or client ? If yes can you please point to some exmaples or documentation.

Can some please give their thoughts on above possibilities/questions.

Thanks,
Bhargav

hello @BhargavModepalli,

recommended way to import the coverage is XML report from JaCoCo. That way you can also produce the report on another VM than the one where you run the SonarQube analysis. See the guide on producing and importing this report here [Coverage & Test Data] Importing JaCoCo coverage report in XML format.

No, we don’t support other ways to import the report like socket. Also note, that import of binary report .exec is deprecated.

1 Like

@saberduck Thanks, Will sonarqube able to merge two jacoco.xml files ? I see it is giving an option to give paths to multiple files

It will merge the reports, but they should contain distinct set of files. If there is coverage information for the same file, it will be overwritten. You may consider using JaCoCo’s merge instead.
Yes, coverage will be merged. Details are in https://jira.sonarsource.com/browse/MMF-345

1 Like

In fact, I stand corrected, the coverage will be merged even for the same file. Details are in https://jira.sonarsource.com/browse/MMF-345 . Thanks @Godin for correction.