MSBuild SonarQube runner in command line

不想你离开。 提交于 2019-11-30 21:30:47

问题


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?

EDIT:

sonar-project.properties:

sonar.projectKey=shrooms
sonar.projectName=Shrooms
sonar.projectVersion=1.0
sonar.sources=.

sonar.properties:

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:

<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] Analysis of project shrooms (report 4) (done) | time=18179ms

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.

回答1:


Thanks for the additional information.

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.

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).

Either remove test from the project path, or update the regular expression SonarQube property used to detect test projects: sonar.cs.msbuild.testProjectPattern

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



来源:https://stackoverflow.com/questions/31722389/msbuild-sonarqube-runner-in-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!