我在使用 MSBuild SonarQube 运行程序分析项目时遇到问题.SonarQube 数据库和服务器已启动并正在运行,我尝试分析一个示例项目,一切顺利.但是当我尝试分析我的项目时,出现了问题.分析完成,没有错误,但没有分析数据保存到数据库,没有问题,没有代码行数,什么都没有.
I have a problem analyzing a project using MSBuild SonarQube runner. SonarQube database and server are up and running, i have tried to analyze an example project and it all went well. But when i try to analyze my project something goes wrong. The analysis completes with no errors but no analysis data is saved to database, no issues, no lines of code count, nothing.
有人知道可能出了什么问题吗?
Anyone has any idea of what could be wrong?
sonar-project.properties:
sonar-project.properties:
sonar.projectKey=shrooms
sonar.projectName=Shrooms
sonar.projectVersion=1.0
sonar.sources=.
声纳属性:
sonar.jdbc.username=user
sonar.jdbc.password=pass
sonar.jdbc.url=jdbc:jtds:sqlserver://localhost;databaseName=SonarQubeDB;SelectMethod=Cursor
sonar.web.host=0.0.0.0
sonar.web.context=/sonarqube
sonar.web.port=9000
SonarQube.Analysis.xml:
SonarQube.Analysis.xml:
<SonarQubeAnalysisProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sonarsource.com/msbuild/integration/2015/1">
<Property Name="sonar.host.url">http://localhost:9000/sonarqube</Property>
<Property Name="sonar.login">admin</Property>
<Property Name="sonar.password">admin</Property>
<Property Name="sonar.jdbc.url">jdbc:jtds:sqlserver://localhost;databaseName=SonarQubeDB;SelectMethod=Cursor</Property>
<Property Name="sonar.jdbc.username">dbusername</Property>
<Property Name="sonar.jdbc.password">dbpassword</Property>
</SonarQubeAnalysisProperties>
在我运行分析后,服务器日志中只添加了一个新行:
In server log theres only one new line added after i run the analysis:
2015.07.30 17:02:29 INFO web[o.s.s.c.ComputationService] 项目shrooms分析(报告4)(完成) |时间=18179ms
2015.07.30 17:02:29 INFO web[o.s.s.c.ComputationService] Analysis of project shrooms (report 4) (done) | time=18179ms
MSBuild.SonarRunner 日志的最后几行:
Last lines of the MSBuild.SonarRunner log:
5:01:18 PM 17:01:18.906 INFO - Execute decorators...
5:01:19 PM 17:01:19.969 INFO - Store results in database
5:02:05 PM 17:02:05.266 INFO - Analysis reports generated in 9578ms, dir size=82 KB
5:02:08 PM 17:02:08.922 INFO - Analysis reports compressed in 3656ms, zip size=285 KB
5:02:10 PM 17:02:10.704 INFO - Analysis reports sent to server in 1782ms
5:02:10 PM 17:02:10.704 INFO - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/sonarqube
/dashboard/index/shrooms
5:02:10 PM 17:02:10.704 INFO - Note that you will be able to access the updated dashboard once the
server has processed the submitted analysis report.
5:02:14 PM INFO: ------------------------------------------------------------------------
5:02:14 PM INFO: EXECUTION SUCCESS
5:02:14 PM INFO: ------------------------------------------------------------------------
5:02:14 PM Total time: 8:10.724s
5:02:14 PM Final Memory: 14M/310M
5:02:14 PM INFO: ------------------------------------------------------------------------
5:02:15 PM Process returned exit code 0
5:02:15 PM The sonar-runner has finished
5:02:15 PM Creating a summary markdown file...
5:02:15 PM Analysis results: http://localhost:9000/sonarqube/dashboard/index/shrooms
Process returned exit code 0
Post-processing succeeded.
感谢您提供更多信息.
首先,您不再需要 sonar-project.properties
文件来使用 MSBuild SonarQube Runner
分析项目:将其从项目中删除.
First of all, you no longer need a sonar-project.properties
file to analyze projects with the MSBuild SonarQube Runner
: Remove it from your project.
您可能正在尝试分析其完整路径包含 test
的项目.这会导致将该项目检测为测试项目,并将其呈现为 SonarQube 中的测试(您在仪表板中看到的所有指标均来自实际来源,即不包括测试).
You probably are trying to analyze a project whose full path contains test
. This leads to the detection of the project as a test one, and will render them as test in SonarQube (all the metrics you see in the dashboard are on actual sources, i.e. excluding tests).
要么从项目路径中删除 test
,要么更新用于检测测试项目的正则表达式 SonarQube 属性:sonar.cs.msbuild.testProjectPattern
Either remove test
from the project path, or update the regular expression SonarQube property used to detect test projects: sonar.cs.msbuild.testProjectPattern
仅供参考 - 此测试检测机制将在即将发布的版本中更新,因为从包含 test
的文件夹中尝试 MSBuild SonarQube Runner 是很常见的场景:http://jira.sonarsource.com/browse/SONARMSBRU-121
FYI - this test detection mechanism will be updated in an upcoming release as trying out the MSBuild SonarQube Runner from a folder containing test
is quite a common scenario: http://jira.sonarsource.com/browse/SONARMSBRU-121
这篇关于命令行中的 MSBuild SonarQube 运行器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!