what is the source for the code coverage value picked by the jenkins plugin github-pr-coverage-status-plugin - jenkins

We are using GitHub Pull Request Builder Plugin to trigger a build on PR and currently managed to post the test results and we are trying to post code coverage as well from sonarQube.
I have jacoco code coverage report generated.
After build completion, code coverage updated as a comment in gitHub. But not able to understand which value it picked to update the code coverage.
When I click on the code coverage comment in gitHub:
Jacoco Coverage Summary
Sonarqube coverage:
gitHub Comment:
In console build coverage build coverage: 0.19452723
How to find on what basis the build coverage calculated?

Related

Code coverage report using Jacoco agent and Jacoco CLI

Im using jacoco agent and jacoco CLI for generating code coverage report
https://www.jacoco.org/jacoco/trunk/doc/agent.html
https://www.jacoco.org/jacoco/trunk/doc/cli.html
But the report which gets generated is not getting reset:
Steps:
Build and deploy the application code - perform tests - measure code coverage and its say 60% and the next time I repeat, Build and deploy the application code - do not perform any tests and measure code coverage and I expect it to be 0%
but it still shows 60%
How to reset the agent?

How to Publish Jacoco Report in Jenkins Using Jenkins Declarative Pipeline Statage

Can you please any one tell me how can publish the Jacoco Report in Jenkins.
I mean after the pipeline execution done the test report need to show on the jenkins dhash Borad.
You should use jacoco step available with Jacoco plugin
jacoco classPattern: "**/classes", sourcePattern: "**/src/main/java"
https://jenkins.io/doc/pipeline/steps/jacoco/#-jacoco-record-jacoco-coverage-report
You can play around with this on the Snippet Generator available at https://<yourJenkins>/pipeline-syntax/

groovy script for using MSTEST jenkins plugin to generate test report

I am using Jenkins MSBUILD plugin in a Freestyle project which is just fine. I have to specify the location of .TRX file and the test report gets generated.
Now I want to use groovy command so I can take advantage of Jenkins pipeline. can someone help me with batch/groovy command to use .TRX as a input and generate test report in Jenkins UI? I tried below but no success.
mstest.exe /publishresultsfile:"C:\Path_to_file\TestResult.TRX"
Below error occurs
Invalid switch "/publishresultsfile".

How can I force update code coverage trend graphs on failed jobs

How can I publish the results of the code coverage to the trend graph even if the job fails after the jacoco analysis?
For Findbugs, PMD, etc. this can be achieved with the canRunOnFailed setting. Is there something similar for JaCoCo?
On project level I see the trend graph which only considers the successful builds. I would also like to see the coverage graph updated if the job fails.
This is tracked by JENKINS-28479:
ProjectActions (and trend graphs) do not appear for failed projects
This problem is not only related to the JUnit plug-in. In general, every plug-in that has been migrated its actions to a SimpleBuildStep has this problem. The affected source code is in SimpleBuildStep.
A test case that exposes this bug is WarningsPluginTest#should_not_skip_failed_builds_with_option_run_always
This is still open.
Original answer:
This is not specific to the maven jacoco build step: all you need to do is make sure that build step always return "success".
If you are using pipelines, you can wrap your step in a try/catch.
If you are using a regular job definition, you could consider a shell/windows command step where you return 0 (or exit /b 0) after the mvn command.
The next build step would be the mvn sonar:sonar publication one, which will then always be executed.

Jenkins Jacoco Coverage Plugin removes previously generated coverage data if build fails

The problem is so simple, but I have not found a solution yet! I use Jacoco Coverage Plugin in Jenkins. Whenever a build fails, all previous coverage data are gone! I want to know how to avoid that. Is it a bug or something that I'm not aware of?
For example for one fail build, I got this in the console:
Build step 'Execute shell' marked build as failure
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at BUILD level /root/.jenkins/workspace/Project/HTMLReport to /root/.jenkins/jobs/Project/builds/118/htmlreports/HTML_Report
Finished: FAILURE

Resources