Code coverage report using Jacoco agent and Jacoco CLI - code-coverage

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?

Related

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

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?

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.

sonarqube project failed

I am using sonarqube 6.1 which is integrated with Jenkins 2.48. In Jenkins, it is showing my build ran successfully. But in Sonarqube, it is showing Failed.
Jenkins :
POST BUILD TASK : SUCCESS
END OF POST BUILD TASK : 0
Finished: SUCCESS
Sonarqube (Failed in red color) :
[![enter image description here][1]][1]
What "failed" mean in Sonarqube project?
Does it means wrong configuration or wrong iteration with Jenkins?
How can I solve this?
I have checked in background task. Project failed recently but in project summery, it is showing past failed details.
[![enter image description here][2]][2]
The SonarQube analysis is split into two separate tasks:
The 'Sonar Scanner' runs the analysis on the code (which is what happens in your Jenkins build) and packs the results and sends them of to the SonarQube instance.
The 'Compute Engine' (CE) uses the packed results and calculates several quality metrics (for ex. the CE is responsible to update the Quality Gate status)
As your Jenkins build is successful this means that the Scanner did do it's work just fine, but on the CE side it failed to process the results of the scanner.
See Background Tasks documentation on how to obtain the log of the CE task and see why the analysis results processing failed.
The default configuration for SonarQube way flags the code as failed if:
the coverage on new code is less than 80%
percentage of duplicated lines on new code is greater than 3
maintainability, reliability or security rating is worse than A

Can we get jacoco report when test run fails

Can we get jacoco report when test run fails?
During execution of the tests if test gets failed then if we can able to proceed and create report?
If any way to create .exec file when we do manual execution
Thanks,

Setting thresholds values - Java - Static Code analysis - SonarQube Sonar

So we have Checkstyle, PMD, Findbugs as tools which performs static code analysis or work on bytecode to find various issues in code and using them in Jenkins/Hudson (under Post build actions), can turn a build to a unstable, failed, successful build depending upon what threshold values we set there.
As SonarQube is the upcoming/future single dash for showing all such analysis in one page for a project/module, I was wondering where in SonarQube settings (I can set such threasholds) to make a build as a failed, unstable, successful i.e. Jenkins will launch the build (ANT/Maven/Gradle etc), calls, sonarRunner (task in Gradle) / sonar-runner (executable in Linux/Unix), then if threasholds are not good, then Jenkins will mark the build as unstable/failed/successful depending upon the set threashold values.
Any ideas?
See alerts / Quality Gates section in SonarQube.(http://docs.codehaus.org/display/SONAR/Quality+Profiles#QualityProfiles-alertsEditingAlerts) and Build Breaker plugin (http://docs.codehaus.org/display/SONAR/Build+Breaker+Plugin).

Resources