code-coverage-api-plugin
code-coverage-api-plugin copied to clipboard
Add remote API for new model
The previous coverage model supports a remote API to obtain the coverage results. This needs to be added for the new model as well.
Old implementation: https://github.com/jenkinsci/code-coverage-api-plugin/blob/master/plugin/src/main/java/io/jenkins/plugins/coverage/targets/RestResultWrapper.java
New implementation should follow a similar pattern as in: https://github.com/jenkinsci/warnings-ng-plugin/tree/master/plugin/src/main/java/io/jenkins/plugins/analysis/core/restapi.
The remote API should provide the results of the coverage analysis in a similar way as the warnings plugin provides the results. So we basically need:
- A top-level API method that returns an overview for the
ResultAction
that contains the model data of the overview. - Optionally: additional API method that returns the delta information for the
ResultAction
(coverage of a change set) - Optionally: additional API method that return the rows of the coverage table for the
ResultAction
that contains the model data of the overview.
Hey Can I do this ?
Yes, please go ahead. If you need more details please let me know!
Is there no REST API then for coverage in any form at the moment? (Version 2.0.4) Then I think this should be mentioned in the README and release notes.
Well, it is tracked as this issue. Feel free to add it to the README as well.
Having to back out our support for code-coverage-api
plugin within our CI framework as we require the REST API for downstream analytics. Unfortunate as this plugin looks better (within Jenkins) than cobertura
.
Hopefully this issue will be fixed and we can revert.
@chinmaym07 Did you make any progress with this?
I think we are now ready to start working on this issue.
What elements or results do you want to see in such an API call? Just the coverage results per metric?
I would like to take over if that is ok
We use the numerator and denominator for each type of coverage, rather than the pre-calculated percentage - e.g. number of lines covered vs total number of lines counted - as this provides a measurement of the "size" of a project when comparing results.
Hi all, is there any progress on this?
I am relying on the API methods to generate a nice github comment for each PR to show how much tests were added and indicate a trend for the current PR if merged.
Unfortunately, not. Seems that nobody really did start working on this topic yet. Maybe this would be a good Hacktoberfest issue, I will mark it as such.
Hello, Can anyone help me understand the requirement? I can pick this issue.
I updated the title now. What else can I do to make it more clear?
Do we have any progress on this? We were using the API(../coverage/result/api/json?depth=2
) to get the coverage results. Are u aware of any alternatives to this? Any help would be appreciated.
Yes, this is already part of #512. You can install a snapshot if you want to test.
to get the coverage results.
What results are you actually expecting? The test of the new API is available at https://github.com/jenkinsci/code-coverage-api-plugin/blob/coerage-model/plugin/src/test/java/io/jenkins/plugins/coverage/metrics/steps/CoverageApiITest.java
@uhafner This was the information we are using with the endpoint ../coverage/result/api/json?depth=1
Ok, the current PR exposes the same results in a different schema, but you should find everything you need.
{
"_class" : "io.jenkins.plugins.coverage.metrics.steps.CoverageApi",
"modifiedFilesDelta" : {
},
"modifiedFilesStatistics" : {
},
"modifiedLinesDelta" : {
},
"modifiedLinesStatistics" : {
},
"projectDelta" : {
},
"projectStatistics" : {
"branch" : "81.51%",
"class" : "90.91%",
"complexity" : "666",
"complexity-density" : "+51.00%",
"file" : "95.83%",
"instruction" : "87.50%",
"line" : "88.21%",
"loc" : "1306",
"method" : "84.32%",
"module" : "100.00%",
"package" : "66.67%"
},
"qualityGates" : {
"overallResult" : "SUCCESS",
"resultItems" : [
{
"qualityGate" : "Overall project - Line Coverage",
"result" : "SUCCESS",
"threshold" : 60.0,
"value" : "88.21%"
},
{
"qualityGate" : "Overall project - Branch Coverage",
"result" : "SUCCESS",
"threshold" : 60.0,
"value" : "81.51%"
}
]
},
"referenceBuild" : "-"
}
Do we have the snapshot version available online? Otherwise can u guide me to the steps for creating it? Also when is the planned release for this, it would be very helpful? And could you help me understand why the format for the result was changed?
I also have a pretty basic question just so i am not missing anything, The plugin page (https://plugins.jenkins.io/code-coverage-api/) still has the entry
but these endpoints are not available anymore..
No, there are no snapshots available right now. You need to wait for the beta version.
You can watch PR #512 to see when it is merged.
The plugin page (https://plugins.jenkins.io/code-coverage-api/) still has the entry
but these endpoints are not available anymore..
Yes, the documentation needs to be updated as well. Feel free to submit a PR once the changes have been merged.
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.
@uhafner I see the minimum jenkins Version required for this version is bumped up to 2.387.1
and we have 2.361.2. Is it possible to downgarde the jenkins version, if there is any help required i would be glad to help since this is a core requirement for us.
This is not possible since I am using features of Jenkins 2.385.