首页 > 解决方案 > 请检查包含/排除模式是否会为主文件和测试文件生成不相交的集合

问题描述

詹金 2.289

爪哇 11

声纳-7.9.1

这是我的 Jenkins 使用插件“SonarQube 扫描仪”的工作:

# 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

但工作得到错误:

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

标签: jenkinssonarqubesonarqube-scan

解决方案


您似乎正在使用 Maven SonarQube 插件的“sonar”目标,因此您不应指定“sonar.sources”值。这是由插件完成的。Maven 使用 pom 的知识为 SonarQube 扫描器提供参数。同样对于“sonar.java.binaries”。

一旦你解决了这个问题,你可能会发现你没有得到任何承认的测试覆盖率。我相信您对“sonar.jacoco.reportPath”属性的使用已经过时。你可以先验证一下。


推荐阅读