dotCover Upload to Sonar from Jenkins Plugin - jenkins

So I am having trouble uploading our dotCover results from Jenkins to our Sonar instance. We are using the SonarScanner for MSBuild plugin. All of the documentation I have found like here: https://docs.sonarqube.org/pages/viewpage.action?pageId=6389770#CodeCoverageResultsImport(C#,VB.NET)-dotCover
Shows how to do it from the command line. We are using the plugin. There is an area for additional arguments that I have added what I assume is an added argument like on the command line. Here is how I have it set up:
So that is the argument that everything shows to add to the end of the command line portion, but for some reason it doesn't add coverage to Sonar. Does anyone see anything obvious I am missing here? I have been stuck on this for a while. Thanks!!

So as it turns out I had:
/d:sonar.cs.dotcover.reportsPath=
It should have been with an s at the end:
/d:sonar.cs.dotcover.reportsPaths=

Related

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

Unable to generate cucumber report through jenkins

I am having error “Could not parse build number : ${${build.number}} while executing maven / java project through Jenkins.
If i run directly through Maven it works.
Any idea what could be the cause of this issue?
Thanks
You can refer the build number directly like,
${BUILD_NUMBER} instead of ${${build.number}}
otherwise you can pass it from goals and options sections.
clean install -Dbuild.number=${BUILD_NUMBER}
then you can refer it in POM like ${build.number}
Use ${env.BUILD_NUMBER} instead of ${${build.number}}

How can I get JSHint configured on a Jenkins server?

I'm relatively new to Jenkins and I'm attempting to add JSHint to my build process. Currently, I have the "Checkstyle Plug-in", "JSHint Report Plug-in", and "Violations plugin" installed on my Jenkins server. In 'Jenkins->Configure->Build->Execute shell' I have the following:
jshint --verbose --reporter=checkstyle > jshint.xml || exit 0
But I'm not exactly sure what's going on here. I found similar commands on other tutorials, but they were half-baked and didn't fully explain what this line of code does.
My goal is to run JSHint on my Jenkins server and send the output/results from JSHint to a file that I can then email to the admin. Any explanation about what the above line of code is suppose to do would be much appreciated. Any links or suggestions on how to add JSHint to a Jenkins build would also be helpful. Thanks ahead of time!
First part of command:
jshint --verbose --reporter=checkstyle
is jshint call with two parameters to turn on verbose mode and export report in checkstyle compatibile format. (Checkstyle is used because Jenkins was originaly designed for Java and Checkstyle is one of Java linting tools -> Jenkins Checkstyle plugin can pick up such formatted report)
Second part:
> jshint.xml
Is linux shell redirection from standard console into file called jshint.xml. This will save your report into file.
Third part:
|| exit 0
Seem to me unnecessary because it does logical OR with exit code values of commands on both sides. Command on right side is saving jshint report into file and command on right side returns 0 error code. So final error code seem to be output of command on right side anyway.

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

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).

Jenkins on Windows using something other than ant

I am looking at using Jenkins on Windows.
I currently have an ant script. It works pretty well. Except for instance, when the build breaks because of a syntax error, I can not see the error in the Jenkins console log.
So I am thinking may be ant is not the best tool for use on Windows.
What do most of you use for Jenkins on Windows?
If it is ant, how do you send the build output, VStudio, to the Jenkins console?
Thanks
Primarily I use Jenkins with maven projects, although you should see the ANT output in the online logs regardless.
What are you building? Are you building Java projects? Ant is what you use. If you are bulding a C project, you should use Make. If you're building a VisualStudio project, you should use msbuild. You use the build tool for your project. Jenkins will execute them without a problem.
Take a look at the build in question. On the left side of the screen, there's a Console output item. Click on that. Is there any output. No matter what tool you use, Jenkins captures the STDOUT and STDERR in that console output. If nothing else, you should see the exact commands Jenkins is executing to checkout and to build your project. Try executing those commands.
Still, you didn't give us much to go on. No idea what you're building or what you're doing with Ant. You didn't state any error, the console output, or even what the Jenkins error log is stating.
Jenkins does two things:
It watches your repository for changes.
Once it detects the changes, it executes the very commands you'd execute to build the project.
Jenkins doesn't care whether you use Ant, Maven, Make, or simply do a del /s/q. Jenkins will simply execute the commands you tell it to execute.
Addendum
It is c, c++, Java and InstallShield. I use ant to do file copy and move, call msdev.exe project. Some Javac calls, InstallShield command line builds..
Jenkins can execute multiple step builds in a single job. After you specify the build step, you can press the Add button to add another build step. There's no reason that all the build steps even have to be of the same type. Just select a "Freestyle" build, and use the right build tools for the job.
There's an optional MSBUILD plugin in Jenkins that should do your MS Build. This should give you the complete output from MSBuild, so you can see any errors.
After you do your MSBuild step, you can create a second build step to run an Ant task to build your InstallShield. After that, you could run another build step to do the copying you need either on the command line or through something like Ant (or Nant.
Whatever the output of the various tools is the output you'll get in the build console.
dev.cmd shows the output and I continue to use ant.

Resources