I have a problem to integrate SONAR and resharper output.
Here is the process I have :
With JENKINS and SONAR integration (sonar-scanner for ms build), I do not want to use roslyn analysis output but I would like to use R# (resharper) analysis. What I do is :
I run resharper command line tool to analysis a solution.
"E:\Jenkins\tools\JetBrains.ReSharper.CommandLineTools.2018.2.3\InspectCode" "E:\Jenkins\workspace\TPStrings\TPStrings.sln" --project=TPStrings --swea -s=INFO -o="E:\Jenkins\workspace\TPStrings\TPStrings.ReSharperReport.xml"
Convert R# output into sonar output using dotnet-reqube.exe which turns R# output to JSON sonar output.
Start SonarScanner.MSBuild.exe and reference my previous JSON sonar output using externalIssuesReportPaths parameter
Run my build
Delete the roslyn files from MSBUILd analysis so that there are not taken into account by sonar.
End SonarScanner.MSBuild.exe : SonarScanner.MSBuild.exe end
Here is the output I get :
Empty project issue
but R# analysis errors are present :
R# imported rules
Why the project summary not well created with externalIssuesReportPaths?
I am expected to get something like :
Expected result
Thanks for you help.
Related
I'm using SonarQube and Jenkins. In Jenkins, I check the unit tests with nUnit and the coverage with opencover. The opencover's report is displayed in Sonar but the nunit's report is not. The Unit Tests count is not even displayed in the home page of the project.
Here is what I do :
Build my VisualStudio project with MSBuild
Run nunit and opencover with a batch command line
Run SonarQube scanner's analysis
Package the project
The Step 2's command line :
MKDIR "%WORKSPACE%\reports"
MKDIR "%WORKSPACE%\reports-history"
SET COV_PTH="D:\Programmes\opencover.4.5.3522"
SET TOOL_PATH="D:\Programmes\NUnit-2.6.4"
SET RPT_PATH="D:\Programmes\ReportGenerator"
copy src\Foo.Bar.Tests\app.config build\Foo.Bar.Tests.dll.config
%COV_PTH%\OpenCover.Console.exe "-filter:+[Foo.Bar*]* -[Foo.Bar.Tests]* -[Foo.Bar.Service]* -[Foo.Bar.Domain]* -[Foo.Bar.Dal]Foo.Bar.Dal.Dao.* -[Foo.Bar.Controller]Foo.Bar.Controller.*Comparer -[Foo.Bar.Controller]Foo.Bar.Controller.External.*" -register "-target:%TOOL_PATH%\bin\nunit-console.exe" -targetargs:"build\Foo.Bar.Tests.dll /noshadow /result=reports\TestResult.xml" -output:reports\opencovertests.xml
%RPT_PATH%\ReportGenerator.exe "-reports:reports\opencovertests.xml" "-targetdir:reports-ReportGenerator" "-historydir:reports-history"
The Step 3's parameters :
sonar.projectKey=FooBar
sonar.projectName=FooBar
sonar.projectVersion=%SVN_REVISION%
sonar.sources=src/Foo.Bar.Controller, src/Foo.Bar.Dal, src/Foo.Bar.Domain, src/Foo.Bar.Fichier, src/Foo.Bar.Generation, src/Foo.Bar.Reporting, src/Foo.Bar.Service, src/Foo.Bar.Web
sonar.binaries=Build/Foo.Bar.Controller.dll, Build/Foo.Bar.Dal.dll, Build/Foo.Bar.Domain.dll, Build/Foo.Bar.Service.dll, Build/Foo.Bar.Fichier.exe, Build/Foo.Bar.Generation.exe, Build/Foo.Bar.Reporting.exe
sonar.tests=src/Foo.Bar.Tests
sonar.cs.opencover.reportsPaths=reports/opencovertests.xml
sonar.cs.nunit.reportsPaths=reports/TestResult.xml
EDIT
I also tried the following process (same results) :
Prepare SonarQube scanner's analysis
Build my VisualStudio project with MSBuild
Run nunit and opencover with a batch command line
End SonarQube scanner's analysis
Package the project
END EDIT
The nUnit's report is well generated in workspace/reports/TestResult.xml.
I tested the analysis generation by command line and via the sonarqube plugin for jenkins. I got the same results.
Can you see anything wrong?
Is there any SonarQube's logs that I could checked ?
I am using Jenkins 2.10, MSBuild 12, SonarQube 5.6, SonarQube scanner for Jenkins plugin 2.4.3, opencover 4.5 and nunit 2.6.4
EDIT
I updated my config : Jenkins 2.18, MSBuild 14, SonarQube scanner for Jenkins plugin 2.4.4. Same results.
END EDIT
Take a look at: SonarQube documentation: Unit Test Execution Results Import (C#, VB.NET)
It says:
Drilldown on Test Execution Results is not supported
My understanding is that you can only see the results (number of Tests passing, errors, etc) but not detail from the tests.
You also ask about Logs. You have:
Jenkins Job log
SonarQube Background tasks: Login as Admin -> Administration -> Projects -> Background tasks -> far right of each execution ---> http://docs.sonarqube.org/display/SONAR/Background+Tasks
SonarQube logs: sonar_install_directory\logs
Using Jenkins I am trying to pass the result of the Nunit task and the OpenCover task to SonarQube.
SonarQube displays properly the test coverage but there is no trace of unit test results.
Here is what I do :
Build Visual Studio project with MSBuild
Batch windows for opencover via nunit
Launch SonarQube scanner
Batch windows for deployement
Here is my actual properties for the Sonar Scanner task:
sonar.projectKey=FC
sonar.projectName=FC
sonar.projectVersion=%SVN_REVISION%
sonar.sources=src
sonar.binaries=build
sonar.exclusions=src/FC.Test/**/*.*
sonar.tests=src/FC.Test
sonar.cs.nunit.reportsPaths=TestResult.xml
sonar.cs.opencover.reportsPaths=reports/opencovertests.xml
I'm using SonarQube 5.6, Jenkins 2.10, SonarQube plugin 2.4.3, OpenCover 4.5 and Nunit 2.6.4
Is there any known problems (compatibility issues...) ?
Note that I tryed to wrap my process with the Prepare and Terminate Sonar analysis tasks but it systematicaly deletes the coverage panel. So i removed it.
EDIT 2017
I stopped doing this way. I understood that the good way to do this was using the SonarQube Scanner for MSBuild which is integrated at the Jenkins's plugin.
The coverage panel was not shown because i didn't configure my quality profiles properly.
But...
I still don't have my tests' result in Sonar.
I checked the absolute path of my report and its parsing by sonarQube : "INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=25ms". I also tryed with a .nunit file. I saw that apply a filter to opencover could help, so I did.
Do you have a clue?
Scanning C# projects requires to use the Sonar Scanner for MSBuild and follow a specific 3 steps process which I guess you don't follow for now. See doc about the 3 steps process at: http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild and http://docs.sonarqube.org/display/SCAN/From+Jenkins
Your properties look correct. Yet they shall not be provided in a sonar properties file but instead in the command line arguments of the MSBuild.SonarQube.Runner.exe begin step, for example:
MSBuild.SonarQube.Runner.exe begin <allMandatoryParameters> /d:sonar.cs.nunit.reportsPaths=TestResult.xml /d:sonar.cs.opencover.reportsPaths=reports\opencovertests.xml
Olivier
I have been setting up SonarQube analysis from a TFS 2013 build using the instructions made by Microsoft ALM Rangers:
https://vsarguidance.codeplex.com/downloads/get/1452516
It all Works fine, until I add ReSharper analysis, then i get an error;
09:51:49: ERROR: Error during Sonar runner execution
09:51:49: ERROR: Unable to execute Sonar
09:51:49: ERROR: Caused by: The property "sonar.resharper.cs.reportPath" must be set.
I have added a sonar-project.properties file to TFS in the same directory as my solution file.
The file looks like:
sonar.resharper.projectName=CommonComponents
sonar.resharper.cs.reportPath=resharperresults.xml
Im using SonarQube 5.1 and the R# 2.0 plugin
Running analysis from Jenkins Works fine.
I really hope you can help me out of this. Im pretty sure its something stupid that I just can't turn my eyes around to see.
The support of the R# by the MSBuild Runner is only going to become available in the version 1.0 of the MSBuild Runner & 2.0 of the R#. See the following tickets:
http://jira.sonarsource.com/browse/SONARMSBRU-16
http://jira.sonarsource.com/browse/SONARRSHPR-15
We have a Jenkins master hosted by Cloudbees and we are using Sonar-as-a-Service.
We have a regular maven project, and we are using the Sonar "Post Build Action" to successfully collect code coverage. I see the code coverage % in Sonar. Everything works fine.
My question is this: If I examine the Jenkins workspace of this project, I cannot find the code coverage results. I thought it would be saved in an xml file somewhere in the target directory, but i do not see it. Does sonar save the results in the Jenkins workspace somewhere?
Thanks!
Sonar uses Jacoco by default for test coverage, this one uses a binary file afaik
I agree that this question is asked many a times by many people and many solutions are already been provided. However, after referring to umpteen links, not being able to display the Emma report in Sonar is driving me crazy. Below is a description of what I am trying to do.
My java project is a multi module maven project. We are using EMMA as the code coverage tool and Jenkins to build the project, Sonar to analyze the code and configured Sonar for our build job using the Jenkins sonar plugin. Up to this point, the story is great. The problem comes when I try to reuse the reports generated by Emma during Sonar analysis. There is no apparent error in the Sonar analysis logs during the build, however, in Sonar project dashboard the coverage report is 0%. Below is configuration data that I provide in the Sonar configuration section of my Jenkins build job.
-Dsonar.core.codeCoveragePlugin=emma
-Dsonar.emma.reportPath=/target
-Dsonar.dynamicAnalysis=reuseReports
-Dsonar.surefire.reportsPath=/target/surefire-reports
Sonar Version : 3.0
Emma plugin versions:
emma-maven-plugin : 1.0-alpha-2
Sonar Emma Plugin :1.0.1
emma : 2.0.5312
The Maven build generates the coverage.em files in the individual modules' target folder. No coverage.ec file is generated. Is it mandatory to have both coverage.ec and coverage.em files for Sonar?
The coverage.es,html,txt,xml files are generated in the project build directory/emma folder
The Sonar analysis logs for a module looks like below.
[INFO] [15:06:02.829] Sensor org.sonar.plugins.emma.EmmaSensor#bfc33...
[WARN] [15:06:02.844] Resource will be ignored in next Sonar versions, index is locked: com.mycompany.mypackage.tests.util.Activator
[INFO] [15:06:02.876] Sensor org.sonar.plugins.emma.EmmaSensor#bfc33 done: 47 ms
The above logs make me think that Sonar is indeed doing something with the generated Emma reports, but not displaying anything on the Sonar project dashboard.
Please let me know where I may be going wrong or what additional thing needs to be done to get this working.
I think this thread might me useful. http://sonar.15.n6.nabble.com/Receiving-quot-index-is-locked-quot-warning-when-Emma-sensor-runs-td4676490.html
It describes the same problem and gives you some workarounds