Using Gallio with OpenCover coverage-report file contais result but Sonar reports 0% - jenkins

I have the problem that the code coverage for some reason aren't presented in Sonar.
The result of the unit tests is performed and showed correctly but not the result of the code coverage. The project is build by Jenkins. I have registered the opencover.profiler.dll file as suggested in some threads but still I get no result. Neither I get any error messages in Jenkins when performing the build.
I would be most grateful for any tips on what to do.
Best regards Dan

I think this happens because your Jenkins service is running as "Local System account", but Sonar is running OpenCover with the -register:user switch under the hoods. You should be able to bypass this either by running the Jenkins service as a regular user account, or patch the Sonar-runner to omit the -register:user switch.

It turned out however that the PDB-files caused the problems. They were included in the repository and were for some reason not recreated by the build in Jenkins. The PDB-files therefor contained the wrong path to the actual code files.
Thanks for the help!

Check for version conflicts between OpenCover and the Gallio plugin.
I found that the later versions of OPenCover (starting with Version 4.0.1229) inserted a new tag in the coverage-report.xml file - which the Gallio plugin could not understand. When I rolled back to an older version of OpenCover (4.0.804) the coverage worked again.
You can find more details on http://sonar.15.n6.nabble.com/coverage-report-xml-is-generated-but-sonar-says-coverage-is-0-td5008850.html
It looks like the Gallio plug-in has been updated, but I haven't pursued that yet (wanted to first confirm that this was the cause of the problem).

Related

How do I user Jenkins warnings-ng-plugin - SonarQube Analysis?

I just installed "Jenkins Warnings Next Generation Plugin" and was wondering how to use the "SonarQube" Static Analysis Tools there.
I found out, that it will parse the result of "sonar-report.json" but I don't know how this files is being generated.
Looking in the SonarQube Documentation I only found out, that the "sonar-report.json" was generated using the "preview mode" which is deprecated since SonarQube 6.6
Does anyone have an Idea how to generate this file with then newest SonarQube (7.4+) or is the Warnings Plugin for SonarQube useless?
Thanks
As mentioned in SonarSource Community it is possible to generate the sonar-report.json using
sonar-scanner -Dsonar.analysis.mode=preview -Dsonar.report.export.path=sonar-report.json
Nevertheless this parameter is marked as deprecated and should not be used anymore
WARN: The use of the issues mode (sonar.analysis.mode=issues) is deprecated. This mode will be dropped in the future.

Getting an "Error while reading the sourcefile!" error from Jenkins jacoco plugin

My source code is written in scala. I have used sbt-jacoco sbt plugin of version 3.0.3 for code coverage. Jenkins plugin used is JaCoCo Plugin of version 3.0.1
I have implemented jacoco within my Jenkinsfile as :
step([$class: 'JacocoPublisher', sourcePattern: '**/src'])
The plugin works perfectly fine , shows the code percentages covered and missed. But when I go to check the actual lines of code covered through the Jenkins UI, I get the above error "Error while reading the sourcefile!"
Would you help me figure out what I am doing wrong?
Attached screenshots
look at jenkins log (usually at /var/log/jenkins/jenkins.log) for exceptions like java.io.FileNotFoundException to figure out where the plugin think the file located at, or any other errors while trying to read the file.
what solve it for me was setting the sourcePattern to '**/src/*/java'
which by default it is set to '**/src/main/java'
based on git

Sonar 5.2 & Cobertura Plugin doesn't work

We upgraded to Sonar 5.2. But now, the task to process the sonar report fails:
2015.12.21 16:08:20 ERROR [o.s.s.c.t.CeWorkerRunnableImpl] Failed to execute task AVHFFR9SqYJURQAYr8yb
java.lang.IllegalArgumentException: There's no changeset on line 59
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:125) ~[guava-17.0.jar:na]
at org.sonar.server.computation.scm.ScmInfoImpl.getChangesetForLine(ScmInfoImpl.java:64) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.scm.DbScmInfo.getChangesetForLine(DbScmInfo.java:69) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.step.NewCoverageMeasuresStep$NewCoverageCounter.initialize(NewCoverageMeasuresStep.java:391) ~[so
If I uninstall the Cobertura Plugin which has version 1.6.3, then the report process works fine. But that's no solution for me because I need these reports. Did anybody succeed to solve this error in another way?
regards
Two thoughts:
1) Your issue seems related to this discussion on SonarQube's group. Check if you have such line number="0" in your cobertura.xml file. Unfortunately the fix is planned for SonarQube 5.4 (i.e. 04/Mar/16.)
2) Depending on your exact needs related to Cobertura reports generation and if you're using Maven, you can try to use QualInsight Maven Cobertura plugin to generate your Cobertura reports. This plugin provides the qualinsight-mojo-cobertura-core mojo, an alternative to the cobertura-maven-plugin mojo you're probably using if your build is Maven based. QualInsight Maven Cobertura plugin generates separate reports for UTs, ITs, and combined Overall Test coverage. It generates standard cobertura.xml reports, but also is able to convert them to SonarQube Generic Test Coverage plugin format.
Maybe generated reports by qualinsight-mojo-cobertura-core won't contain data causing issues + maybe using SonarQube's Generic Coverage plugin instead of SonarQube's Cobertura plugin won't cause the exception you get (it was released 9 days ago and tested towards SQ 5.2, while the Cobertura plugin was last released in September 2014)
If want to give it a try and need help / have questions with this solution, just ask (I'm the developer QualInsight Maven Cobertura plugin.)
Regards,

Travis-CI and Coveralls

I just cannot hook up the automatic update of coveralls.io to my Travis-CI build. All works fine if I execute the scripts on my machines. Here is the last message from the build log:
Submitting coverage to coveralls.io...
Coverage submitted!
Couldn't find a repository matching this job.
'url'
The command "python travis-ci/run.py" exited with 0.
Any hints or suggestions would be highly appreciated.
Best, Philipp
Make sure the TRAVIS, TRAVIS_JOB_ID and TRAVIS_BRANCH environment variables are defined when calling coveralls.
If you're using Tox for example, an extra step is needed as described in the coveralls-python readme.
This question is older, but the current problems show the same error. (And Google finds this too :-))
There were issues opened about it in node-coveralls and coveralls-public (and one more) repositories. It appeared, that Coveralls got accidentally blocked by Travis.
Although the problem was supposed to be fixed, as the comments on the second issue suggest, it occurred again. I myself could upload a new report neither from my machine, nor from Travis. I switched from Coveralls to Codecov.

Gallio not working with sonar-runner

I'm trying to get sonar-runner to run Gallio and OpenCover on my .net application.
I've set up the following:
Sonarqube v4.3.2
Gallio v3.4.14
NUnit v2.6.3
OpenCover v4.5
Sonar-runner v2.4
Here is what I have in my sonar-project.properties file (the things conserning Gallio)
\#Gallio
sonar.gallio.mode=
sonar.gallio.coverage.tool=OpenCover
sonar.donet.visualstudio.testProjectPattern=*Test*
sonar.opencover.installDirectory=C:\\Program Files (x86)\\OpenCover\\
sonar.dotnet.test.assemblies=**\\bin\\Debug\\*.Tests.dll
sonar.gallio.runner=Local
I have tried all sorts of variations of this config file but the weird thing is that when I run sonar-runner, even with parameters -X or -e, there is absolutely no mention of Gallio or OpenCover in the output. It's like the sonar runner is just skipping the Gallio section completely!
Does anyone here have a clue of what might be going on ?
Latest versions of the C# Plugin do not support the automatic execution of Gallio (see this documentation).
Starting with C# 3.0, only the reuse of reports is supported to get test and coverage information for .NET projects. Please read the documentation page of the C# plugin to know how to do that.

Resources