Alexei
Alexei

Reputation: 15646

Please check that inclusion/exclusion patterns produce disjoint sets for main and test files

Jenkin 2.289

Java 11

sonarqube-7.9.1

Here my Jenkins's job that use plugin "SonarQube scanner":

# Language
sonar.language=java

#BaseDir
sonar.projectBaseDir=/home/myUser/.jenkins/workspace/my-project-sonar/my-project


# Set modules IDs
sonar.modules=my-project-common,my-project-dalReader,my-project-mediation,my-project-reports,my-project-server,my-project-dal,my-project-dalWriter,my-project-sdn


# Modules inherit properties set at parent level

sonar.sources=./
#sonar.sources=**/src/main/**

#**/src/**

sonar.exclusions=**/generated-sources/**,**/src/test/**,**/*Header.java,./.svn,./my-project-it,./my-project-parent,./my-project-client

# By default, the base directory for a module is <current_dir>/<module_ID>.
common-model.sonar.projectBaseDir=common-model
my-project-common.sonar.projectBaseDir=my-project-common
my-project-sdn.sonar.projectBaseDir=my-project-sdn

sonar.junit.reportsPath=**/target/surefire-reports/*

# Comma-separated paths to directories containing the compiled bytecode files corresponding to your source files
sonar.java.binaries=**/target/classes/**

# Tells SonarQube where the unit tests code coverage report is
sonar.jacoco.reportPath=**/target/jacoco-ut.exec

# Encoding of the source files
sonar.sourceEncoding=UTF-8

But job get error:

INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 15.111s
INFO: Final Memory: 13M/550M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
ERROR: File myproject-server/server-deployment/pom.xml can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?
ERROR: SonarQube scanner exited with non-zero code: 2
Finished: FAILURE

Upvotes: 0

Views: 3576

Answers (1)

David M. Karr
David M. Karr

Reputation: 15205

You appear to be using the Maven SonarQube plugin's "sonar" goal, so you should not specify a "sonar.sources" value. That is done by the plugin. Maven uses the knowledge of the pom to provide parameters to the SonarQube scanner. Similarly for "sonar.java.binaries".

Once you get past this problem, you may discover you're not getting any test coverage acknowledged. I believe your use of the "sonar.jacoco.reportPath" property is obsolete. You can verify that first.

Upvotes: 1

Related Questions