1
votes

Sonar Runner stepWe are trying to setup Sonar for a project(Modules) in TeamCity. We have the following build steps: 1) Nuget Install 2) Visual Studio sln 3) Inspections(.Net) 4) Sonar Runner

In the Sonar Runner step,it is unable to get hold of that file.see image 2 unable to find that xml file

Please help by pointing me in the right direction on how to make it pick the xml file.

1
Can you show the full log for the step, from starting SQR? Would be nice to see what it's initialising the values to before the error, e.g. -Djava.io.tmpdir=C:\Data\TeamCityAgent01\temp\buildTmp, but all of them will be useful to try and diagnose this. Is the runner using the DEFAULT JDK path?Evolve Software Ltd
it is using the default jdk path. I have included the sonar runner step log in my post(description:Sonar Runner Step)Nischith

1 Answers

3
votes

The main trick here is to pass report XML to SonarQube runner - it could be done with /output resharper option (see step #2 below). There are though some more things which could ruin your day so I composed a full procedure.

  1. First of all make sure that SonarQube Server is configured correctly to accept Resharper data. You'll need installed Resharper and C# plugins and configured Quality Profile with Resharper rules. To check configuration I recommend running analysis manually as described in the Resharper plugin documentation.

  2. Then configure your Inspections(.Net) TeamCity build step to create report XML in a well-known place: open advanced options and in the field "Additional inspectCode.exe arguments:" add /output=%system.teamcity.build.tempDir%\inspectReport.xml (or any other location). Important! The step will fail because it expects the report in default location (see issue on YouTrack). All subsequent steps will need Execute step: if some of the previous steps failed option to run

  3. In SonarQube Runner step open advanced options and to the "Additional parameters:" field add this 2 lines (replace pathToSolutionFile with real path):

    -Dsonar.resharper.cs.reportPath=%system.teamcity.build.tempDir%\inspectReport.xml
    -Dsonar.resharper.solutionFile=pathToSolutionFile
    
  4. Finally to see the inspections report in TeamCity UI as well add a new Command Line build step with:

    echo "##teamcity[importData path='%system.teamcity.build.tempDir%\inspect.xml' type='ReSharperInspectCode']"