SONAR Code coverage not getting reflected - sonarqube

Issue :
SONAR Code coverage is not getting reflected on Azure DevOps.
We are developing application in C# .NET , the test methods are running successfully however when we push the build in pipeline of Azure DevOps, the code coverage percentage still remains 0%.We tried checking all the possible settings but aren't able to reach on any solution yet. Can anyone let me know which all areas we should be checking to resolve this issue?
Let me know if additional information is required.

Related

Analyse new\updated code only for dotnet projects with sonarcloud

We have setup pull request analysis for C# .Net code. It is observed old code(unmodified) is being considered for analysis which is not expected, this is blocking us from using quality gates.
The new code condition is set based on the “number of days” condition which is set to 1.
Even then the PR/short branch analysis reports issues that are present in old code (which are not updated\edited as part of the pull request), because of this issue we are unable to enable quality gates.
Following tasks are used in the azure devops pipeline:
Prepare analysis for sonar cloud
Run code analysis
Publish quality gate result
ALM used: Git in Azure DevOps CI system used Azure DevOps
Languages of the repository: C# .Net
This is an example SonarQube pipeline configuration which is executed on every merge to the master branch.
Example pipeline steps
Steps:
Node is installed for building purposes
Prepare analysis is initiated which downloads necessary for scanning, configurations and rulesets
Nugget package manager is installed
Nugget restore is initiated
Solution is built (important step)
Code analysis is checking every .cs file contained in the solution previously built
Strict quality gate are the scan results
Custom build step which breaks the pipeline if quality gate has failed
This might be obvious but make sure you are building the C# solution in between the Prepare analysis on SonarQube and Run Code Analysis in order to provide updated code that SonarQube will analyze.
The "Get results from SonarQube" step is a powershell script that calls the SonarQube API to get the quality gate results of the scan initiated in order to fail if issues have been found.

SonarQube with Azurepipelines showing no results

I configure Azure pipelines with react native. I need to analyse the code using SonarQube. Builds are succeeded.But SonarQube shows no issues. The Publish Quality Gate Result shows ['No analysis found in this build! Please check your build configuration.']

getting trouble to generate sonar test report

I am using sonarqube on my windows server, and it is working find from my client PCs, now I need to generation sonar test report in form of file, pdf, html or in any format to display it to my client. I tried but am not getting any solution, would you please help me, that how to export sonar test report from sonarqube server.
You're not finding that "report export" feature because SonarQube is about continually monitoring the evolution of your code, not printing out a point in time and pinning it to the wall.
If you really have to have something like this, then screenshots are the easiest way to go. Alternately, you can pull current state data using web services and build your own report.

Does continuous inspection still work with Sonar 5.1.X?

I'm trying to run a preview analysis for a (Java) project of ours with SonarQube 5.1.1. I am able to get a local report generated, however I get no coverage data, and I also get the message [INFO] [XX:YY:ZZ.ZZZ] Build Breaker plugin is no more supported in preview/incremental mode.
If I check here, the page says that Starting with SonarQube 5.1, the Build Breaker plugin does not work any longer in the preview & incremental modes..
I'm confused - I thought that for continuous inspection one needs the build breaker plugin. Is that no longer so? Has the concept in SonarQube changed?
Why am I not getting coverage data when running a preview analysis?
I don't know where you've read this, but continuous inspection is not specifically related to the preview/incremental mode nor to the build breaker plugin - it's not even related to SonarQube (even though it has been pushed by SonarSource from the very beginning).
Here are the key points:
Continuous inspection is about analyzing your code as often as you can in order to monitor (and eventually improve) the quality of your code. Whatever the tool.
On SonarQube, this means running analyses that will push information on the server so that you can monitor what's going on and take the required actions for your application portfolio.
Obviously, when you are a developer, you'd like to manage those issues early, before they even get pushed to the source code repository. But experience tells us that preventing any code push because of issues is a bad pattern - because some issues might be false-positive or not relevant in the context (and still you want - and have the right, to push your code). This is why we feel that the build breaker plugin is not aligned with all this, and it will be replaced in upcoming versions of SQ by native features that match better these concepts:
Very efficient code analysis to display issues in the IDE at the speed of light - but without computing metrics
Preview mode that will compute everything and make it possible to check quality gate before pushing code to the source code repository - without impacting the results on the server
and in this case, using some specific information found in the logs, it will be possible for a CI to fail a build

Coverage Reports on SonarQube Preview/Incremental analysis

We've recently set our Continuous Integration environment to do an incremental code analysis before a Merge Request on Git can be accepted. We already use the HTML issues report and the Build Breaker plugin. Everything works beautifully. The thing is, we're having some issues because the build is broken on < 85% code coverage. I didn't find any plugin to let the user know where the coverage dropped. Is there any way to show that comparison between the analisys that is recorded on my server and the one Jenkins is incrementally building ?
Thanks a lot!
Im using sonar4.5.4 and we use the Coverage on new code metric in our quality gate, in that metric we compare with the previous analysis

Resources