[英]Running Sonar Code Analysis from Eclipse Instance
We use Jenkins for both building application and running sonar analysis through maven on the code. 我们使用Jenkins来构建应用程序并通过代码上的maven运行声纳分析。
I am able create a local server, and run sonarqube analysis using sonar runner. 我能够创建本地服务器,并使用声纳运行器运行声纳分析。
I was able to connect my eclipse instance to the company sonarqube runner and get the issues from existing analysis on eclipse. 我能够将eclipse实例连接到公司声纳赛跑者,并从对eclipse的现有分析中获得问题。 But while running 'Analyse' from eclipse, it fails.
但是从Eclipse运行“分析”时,它失败了。
It returns, You must define the following mandatory properties for 'Unknown': sonar.sources 它返回, 您必须为“未知”定义以下必需属性:sonar.sources
While I looked into the process, I found that, a temporary sonar-runner is downloaded in the temp folder and a sonar-project.properties is created and the analysis is run using that. 在研究过程时,我发现在temp文件夹中下载了一个临时声纳运行器,并创建了sonar-project.properties并使用该运行分析。 This property file does not have the sonar.sources defined inside it.
此属性文件中没有定义sonar.sources。 Since this property file is not in my control, How to resolve this issue?
由于此属性文件不在我的控制范围内,如何解决此问题?
The sonar-project.properties
config file must be in the root of your eclispe project. sonar-project.properties
配置文件必须位于eclispe项目的根目录中。 And it should looks like this: 它应该看起来像这样:
# Required metadata
sonar.projectKey=nutch-key
sonar.projectName=nutch-prj
sonar.projectVersion=1.0
# Path to the parent source code directory.
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional. If not set, SonarQube starts looking for source code
# from the directory containing the sonar-project.properties file.
sonar.sources=src
# Encoding of the source code
sonar.sourceEncoding=UTF-8
# Additional parameters
sonar.my.property=value
SQ Eclipse plugin will use the configured Eclipse (JDT) source folders and pass them to sonar.sources. SQ Eclipse插件将使用配置的Eclipse(JDT)源文件夹,并将它们传递给sonar.sources。 Check that you have some source folders configured (Right click on project -> Properties -> Java build path).
检查是否已配置一些源文件夹(右键单击项目->属性-> Java构建路径)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.