code-coverage-api-plugin
code-coverage-api-plugin copied to clipboard
Build fails when coverage thresholds are breached but failed module name is not printed
Thanks for resolving https://github.com/jenkinsci/code-coverage-api-plugin/issues/110 . I tested the changes and it works great. Following line appears appears on the build overview page.
Report: 100% Group: 100% Package: 100% File: 100% Class: 100% Method: 99% Line: 94% Conditional: 90%
Build failed because following metrics did not meet stability target: [Conditional {unstableThreshold=95.0, unhealthyThreshold=95.0}].
However status page doesn't report the name of the module which failed the coverage target. But, I see that the name is printed in the exception as below:
Calculating coverage change for change request build is enabled, target branch develop
Code coverage enforcement failed: Conditional coverage in Report level 'istanbul: restService-cobertura-coverage.xml' is lower than 95.00 stable threshold
io.jenkins.plugins.coverage.exception.CoverageException: Build failed because following metrics did not meet stability target: [Conditional {unstableThreshold=95.0, unhealthyThreshold=95.0}].
at io.jenkins.plugins.coverage.CoverageProcessor.processThresholds(CoverageProcessor.java:466)
at io.jenkins.plugins.coverage.CoverageProcessor.performCoverageReport(CoverageProcessor.java:123)
at io.jenkins.plugins.coverage.CoveragePublisher.perform(CoveragePublisher.java:94)
at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80)
at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Would it be possible to add the name of the module 'istanbul: restService-cobertura-coverage.xml' to the failure message on status page?
My configuration for this job was as follows:
applyThresholdRecursively: false,
calculateDiffForChangeRequests: true,
failNoReports: true,
failUnhealthy: true,
failUnstable: true,
globalThresholds: [
[thresholdTarget: 'Class', unhealthyThreshold: 100.0, unstableThreshold: 100.0],
[thresholdTarget: 'File', unhealthyThreshold: 100.0, unstableThreshold: 100.0]
],
sourceFileResolver: sourceFiles('STORE_LAST_BUILD')
Thanks a lot for fixing the previous issue.
However the build status doesn't change to failure
What's your meaning of the build status doesn't change to failure? Is the build not failed?
status page doesn't report the name of the module which failed the coverage target
OK, will add a name to status page :P
Thanks for the feedback :)
What's your meaning of the
build status doesn't change to failure? Is the build not failed?
Yes. The build completes successfully even after the coverage threshold check has failed. The status page shows the line which I posted but the build doesn't actually fail.
I just checked. There was an error in our Jenkins file. Looks like the build does get marked as failed. So that issue is not present. But it will still be good to report the module(s) which failed the coverage thersholds
The new step recordCoverage is now in beta testing, can you please check if this release helps to solve this issue? Please note that the syntax of the step is totally new and cannot be combined with existing results.