JaCoCoSensor finds "sonar.coverage.jacoco.xmlReportPaths" property but it has not been set anywhere

Hello,

here are the required informations :

  • SonarQube version: 7.7.0
  • Scanner : org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131
  • org.jacoco.jacoco-maven-plugin: 0.8.7

The scanner command is as follow :

mvn -X org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar
-Dsonar.scm.provider=git
-Dsonar.projectKey=[project]
-Dsonar.projectName=[project_name]
-Dsonar.host.url=[sonar_url]
-Dsonar.leak.period=previous_version
-Dsonar.links.scm=[scm _url]
-Dsonar.jacoco.reportPaths=target/jacoco.exec,target/jacoco-it.exec
-Dsonar.cpd.exclusions=[exclusions]
-Dsonar.coverage.exclusions=[exclusions]
-Dsonar.exclusions=[exclusions]

There is no sonar configuration in the project.

There is jacoco configuration in the project :

<plugin>
	<groupId>org.jacoco</groupId>
	<artifactId>jacoco-maven-plugin</artifactId>
	<version>0.8.7</version>
	<executions>
		<execution>
		<goals>
			<goal>prepare-agent</goal>
		</goals>
		<configuration>
			<propertyName>jaCoCoArgLine</propertyName>
		</configuration>
		</execution>
		<!-- attached to Maven test phase -->
		<execution>
		<id>report</id>
		<goals>
			<goal>report</goal>
		</goals>
		</execution>
	</executions>
</plugin>

In Sonarqube, the configuration of jacoco is as follow :
JaCoCo Reports / Path to the JaCoCo report files containing coverage data by unit tests. The path may be absolute or relative to the project base directory :

  • target/jacoco.exec
  • target/jacoco-it.exec

My goal is to publish code coverage (and other metrics) in sonarqube.

When the scanner command is run, everything works fine (bugs, code_smell, etc…) but the code coverage, which is always 0 when used from the Jenkins platform.
When used from my own computer, with the same files (.exec), it is OK.

When the scanner command is executed in Jenkins, the following message is displayed :

“Both ‘sonar.jacoco.reportPaths’ and ‘sonar.coverage.jacoco.xmlReportPaths’ were set. ‘sonar.jacoco.reportPaths’ is deprecated therefore, only ‘sonar.coverage.jacoco.xmlReportPaths’ will be taken into account.”

which is a mystery as no “sonar.coverage.jacoco.xmlReportPaths” has been declared in our configuration.

The files are generated by the plugin without problem, and contain correct informations as the scanner command run from my computer works fine.

I know we are not supposed to use the .exec files any more but I read the .xml reports are not read by SonarQube 7.7, and we cannot update Sonarqube (the team responsible won’t hear it).

Why am I getting this message? Am I missing a configuration somewhere?

Thank you in advance for your answer.

Gabriel

I have resolved the problem as follow :
the problem was the presence of .xml files, that had priority on the .exec ones, so despite the fact that the reportPath was set, it was ignored and the xml files were used.
The solution is to delete the xml files so that they are not used by the plugin.

If there is a better solution, I would be glad to read it anyway.

Gabriel

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.