4

I am trying to use C# Plugin for SonarQube using MSbuild.SonarQube.Runner

SonarQube Server - 4.5.6 Operating system - Windows 32-bit machine Database - MySQL 5.6.17 MSbuild.SonarQube.Runner - 1.0.2

Following steps mentioned in http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Scanner+for+MSBuild

Running all the 3 commands from the folder of the project.

  1. First Try

SonarQube.Analysis.xml file contents

<?xml version="1.0" encoding="utf-8" ?>
<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://x.x.x.x:9000</Property>
   <Property Name="sonar.login">userabc</Property>
   <Property Name="sonar.password">1234</Property>
   <!-- Required only for versions of SonarQube prior to 5.2 -->
   <Property Name="sonar.jdbc.url">jdbc:mysql://x.x.x.x:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance</Property>
   <Property Name="sonar.jdbc.username">sonar</Property>
   <Property Name="sonar.jdbc.password">sonar</Property>
</SonarQubeAnalysisProperties>

I tried running first command - MSBuild.SonarQube.Runner.exe begin /k:prj_K /n:prj /v:1.0

but I got below error

 Unable to read the SonarQube analysis settings file 'C:\Sonar\sonarqube-4.5.6\MSBuild.SonarQube.Runner-1.0.2\SonarQube.Analysis.xml'. Please fix the content of this file. 
  1. Second Try

Then the change the property value of sonar.jdbc.url to

<Property Name="sonar.jdbc.url">jdbc:mysql://x.x.x.x:3306/sonar?useUnicode=true</Property>   

After this first command is successful.

Second command

 msbuild /t:Rebuild

is also successful

Third command

 MSBuild.SonarQube.Runner.exe end

I am getting below logs

 INFO: ------------------------------------------------------------------------
 INFO: EXECUTION SUCCESS
 INFO: ------------------------------------------------------------------------
 Total time: 2:02.225s
 Final Memory: 11M/121M
 INFO: ------------------------------------------------------------------------
 Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
 The sonar-runner did not complete successfully
 16:36:59.242  Creating a summary markdown file...
 Post-processing failed. Exit code: 1    

Post-processing failed. Exit code: 1

What I am missing?

Also, Properties in SonarQube.Analysis.xml - sonar.jdbc.username and - sonar.jdbc.password

Why they are required?

Thanks in Advance.

Pascal Berger
  • 4,262
  • 2
  • 30
  • 54
atulya
  • 535
  • 2
  • 8
  • 25
  • Your first try failed because the file isn't valid XML: the *sonar.jdbc.url* value is not properly escaped. Your third try might be failing due to issue [https://jira.sonarsource.com/browse/SONARMSBRU-202](SONARMSBRU-202). As a workaround, try not setting *MaxPermSize*. – duncanp Jan 11 '16 at 09:58
  • @duncanpMS Thanks for reply.
    I am able to successfully run step 3, by removing MaxPermSize.
    But I am not able to access Jira issue mentioned above because I don't have access/login for jira.sonarsource.com.
    – atulya Jan 12 '16 at 05:45
  • it would have helped if I'd formatted the link correctly: [SONARMSBRU-202](https://jira.sonarsource.com/browse/SONARMSBRU-202) You should be able to access it anonymously. – duncanp Jan 12 '16 at 08:49

2 Answers2

2

MSBuild.SonarQube.Runner.exe is incorrectly reporting that processing failed because of the warning about MaxPermSize that was written to the error stream.

This is a known issue, tracked by SONARMSBRU-202. It should be fixed in the next release of the SonarQube Scanner for MSBuild.

The workaround is to remove the warning by not setting MaxPermSize.

duncanp
  • 1,572
  • 1
  • 10
  • 8
0

I took the same mistake. I wrote the wrong way when I added it to PATH. Or, after you add the MSBUILD to PATH, the same error is received even if the MSBUILD was moved to another folder.