I am new to the SonarQube product. To date, we have configured the sonarqube server, the SQL database and integrated the sonarqube runner with team city. We currently have a C#/.NET project that I am attempting to scan. In the scan results, it is showing 0.0 Code Coverage. This codebase is predominately C#/.NET along with some javascript and HTML. In the documentation, https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild , it states how to setup sonarqube for MSBuild however we are using team city to build the package. I have followed this link for the team city, sonarqube integration.https://confluence.jetbrains.com/display/TW/SonarQube+Integration#SonarQubeIntegration-ReSharperinspections(Inspections(.NET)runner)
I am wondering what steps need to be taken in order to gain code coverage on the package. Any help or guidance in the would be appreciated. Thank you.
Thanks for the response. Thatâs what I donât quite get. This is being run though (automated ) Team City. The documentation for team city is here: https://confluence.jetbrains.com/display/TW/SonarQube+Integration#SonarQubeIntegration-dotCoverresults . In reading the documentation you sent me, it looks like for MSBuild is set to: sonar.cs.vscoveragexml.it.reportsPaths , Visual Studio is set to: sonar.cs.vscoveragexml.reportsPaths= **"%CD%\VisualStudio.coveragexml, docCover is set to: etc. The setting I have in Team City is Dsonar.resharper.cs.reportPath=%system.teamcity.build.tempDir%\inspectReport.xml.
This setting within TC should complete the code coverage correct?
Been a while since I have used Team City, however, the property you are using is for the ReSharper static code analyzer, not the property for Code Coverage with DotCover.
Through a lot of trial and error, we were able to get the test execution and unit tests running with dotCover. Reports are being generated, merged and being picked up by Sonarqube. The issue now is that Sonarqube is not reading the code coverage portion of it. Under code coverage, it shows â-â??
So it looks like it is providing coverage on the javascript and css files but not the C# files. in the build log, it is showing that the C# files are being scanned but that is not being populated in sonarqube??
Attached are 2 files. There is one with out the final build step, which is to send to sonarquube anad one with the end build step, send to sonarqube, that fails build. In that log file, there is an error message regarding begin and end step. Documention is iffy and what exactly those steps are supposed to be comprised of? Thank you for your continued help.
Below are the screenshots showing the build process as a whole and the steps setting within the begin and end. I am hoping to verify that everything is correct. Thank you.
@beik could you post a link to the iffy documentation please? If itâs our documentation we can fix it; if itâs for the third-party TeamCity plugin we canât.
Looking at the failing log, the scanner begin step is immediately followed by the scanner end step. That isnât how the scanner is intended to be run. The expected sequence is:
scanner begin
execute the build and test
scanner end
There is more information in the docs for the Scanner for MSBuild here.
EDIT: the ordering in the screenshots looks ok, but doesnât match whatâs in the log files:
[10:22:27]W: Step 3/6: Build Payment (Visual Studio (sln)) (22s)
...
[10:28:00] : Step 4/6: Execute Unit Tests (Visual Studio Tests) (13s)
...
[10:28:14] : Step 5/6: Static Code Analysis (SonarScanner for MSBuild: begin analysis) (1s)
...
[10:28:15]E: Step 6/6: Complete SonarQube Report (SonarScanner for MSBuild: finish analysis)
Iâm not familiar with either TeamCity or the TeamCity plugin for SonarQube (although I see the plugin is using v4.0.2 of the scanner which is rather old and doesnât support either the new SDK-style MSBuild project format or MSBuild v16).
However, the scanner is just a command line tool, and the plugin is just a wrapper around the scanner that is intended to make it easier to provision the scanner onto your build agents and then invoke it for you. Looking at the docs for the scanner should give some pointers on how it you should configure the plugin i.e. the ordering of tasks, and the parameters to pass at each stage.
Alternately, if the plugin isnât helping you then you could just call the scanner directly from script code in your build pipeline.