SonarQube:“项目配置文件:无”

use*_*978 5 java maven sonar-runner sonarqube sonarqube5.1

我已经配置了所有内容来对 Maven 项目进行声纳分析。一切都很好,直到我运行sonar-runner

     Max$ sonar-runner
     INFO: Scanner configuration file: /Users/Max/Documents/sonar-scanner-2.5/conf/sonar-runner.properties
     INFO: Project configuration file: NONE
     INFO: SonarQube Scanner 2.5
     INFO: Java 1.7.0_45 Oracle Corporation (64-bit)
     INFO: Mac OS X 10.10.3 x86_64
     INFO: User cache: /Users/Max/.sonar/cache
     INFO: Load global repositories
     INFO: Load global repositories (done) | time=143ms
     INFO: Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
     INFO: User cache: /Users/Max/.sonar/cache
     INFO: Load plugins index
     INFO: Load plugins index (done) | time=4ms
     INFO: Default locale: "fr_FR", source code encoding: "UTF-8" (analysis  is platform dependent)
     INFO: Process project properties
     INFO: ------------------------------------------------------------------------
     INFO: EXECUTION FAILURE
     INFO: ------------------------------------------------------------------------
     INFO: Total time: 1.631s
     INFO: Final Memory: 40M/194M
     INFO: ------------------------------------------------------------------------
     ERROR: Error during SonarQube Scanner execution
     ERROR: Unable to load component class org.sonar.batch.scan.ProjectLock
     ERROR: Caused by: Unable to load component class     org.sonar.api.batch.bootstrap.ProjectReactor
     ERROR: Caused by: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.projectName, sonar.projectVersion, sonar.sources
     ERROR: 
     ERROR: To see the full stack trace of the errors, re-run SonarQube  Scanner with the -e switch.
     ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
Run Code Online (Sandbox Code Playgroud)
  • sonar-runner在我的 java 项目文件夹中运行
  • 我已经sonar-runner.properties 在我的java项目中放置并配置了

    sonar.projectKey=SeleniumMaven:sonar
    sonar.projectName=SeleniumMaven
    sonar.projectVersion=1.0
    sonar.sources=src
    sonar.sourceEncoding=UTF-8
    sonar.language=java
    
    Run Code Online (Sandbox Code Playgroud)

任何的想法?

Мак*_*тов 6

您需要在项目的根目录中创建一个配置文件: sonar-project.properties

如果无法在项目的根目录中创建(或者您不会)sonar-project.properties文件,有多种选择

  • 可以通过命令行直接指定属性。前任:

    声纳扫描仪-Dsonar.projectKey=myproject -Dsonar.sources=src1

  • 属性project.settings可用于指定项目配置文件的路径(此选项与project.home和sonar.projectBaseDir属性不兼容)。前任:

    声纳扫描仪-Dproject.settings=../myproject.properties

从 SonarQube Scanner 2.4 开始,可以通过sonar.projectBaseDir属性设置要分析的项目的根文件夹(以前是 project.home)。如果未在命令行上指定强制属性(如sonar.projectKey ),则此文件夹必须包含sonar-project.properties文件。

可以在此项目配置文件中或通过命令行参数定义其他分析参数。


Hel*_*rld 5

尝试传递这样的值:

sonar-runner -Dsonar.projectKey=..... -Dsonar.projectName=...

如果它有效,则意味着属性文件有点被忽略

如果您查看以下消息:

INFO: Scanner configuration file: /Users/Max/Documents/sonar-scanner-2.5/conf/sonar-runner.properties
INFO: Project configuration file: NONE
Run Code Online (Sandbox Code Playgroud)

看来您的项目配置文件确实被忽略了


小智 5

我遇到了同样的问题,我意识到我的文件名不正确:我把它作为“sonar-project.properties.properties”而不是“sonar-project.properties”。

我会尝试将您的文件名更改为“sonar-project.properties”并尝试...