feat(jenkins): add metric parameter support for apiv4 coverage plugin [Jenkins]#11794
feat(jenkins): add metric parameter support for apiv4 coverage plugin [Jenkins]#11794ashif323 wants to merge 2 commits into
Conversation
559a99d to
922c182
Compare
The apiv4 format now supports a 'metric' query parameter allowing users to choose which coverage metric to display from the new Jenkins coverage plugin (io.jenkins.plugins.coverage). Supported metrics: line (default), branch, instruction, method, module, file Also updated the description to mention the new Coverage Plugin. Closes badges#11689
922c182 to
1a0c05f
Compare
|
Hello @ashif323 👋🏻 Do you have an example of live Jenkins job that uses the new plugin? |
|
Hi @PyveB 👋 I don't have a live Jenkins job available right now. Could you guide me on what would be the best way to provide a working example? I'm happy to set one up if needed to get this PR over the line! |
|
I don't know how to get a working example, that's why I asked a couple of times on the linked issue. How did you validate these changes are correct and will work? |
|
Hi @PyvesB 👋 I validated the changes by:
I understand this isn't the same as a live Jenkins job. If the maintainers feel a live example is required before this can be merged, I'm happy to look into setting up a demo Jenkins instance with the Coverage Plugin installed. Alternatively, if there's a public Jenkins instance already using this plugin that we could reference, that would also work. Would that be acceptable? |
|
It's always better to have a live example, and I don't think we can add code before testing it at least once with a live example. |
|
I've spent time searching for a public Jenkins instance using
It seems the new Coverage Plugin isn't widely deployed on public Jenkins instances yet, which makes it very difficult to provide a live example. Given this blocker, I have two options:
What would you recommend? I don't want to keep this open indefinitely if a live example is a hard requirement. |
|
I'll try to look for some instances in the coming days. Travelling at the moment, so a little slow to respond. :) |
|
From what I can tell, https://jenkins.mm12.xyz/jenkins/job/nmfu/job/master already uses the new Jenkins code-coverage plugin. As I hinted at in #11689 (comment), our badges already support the latest and greatest Jenkins coverage plugin. I'm still unsure why @markshep and @martontorner-cs claimed it wasn't supported, perhaps we're missing something here. @ashif323 I'd be happy for us to enhance the existing badge with |
|
I looked into the issue deeper and it turns out that both sides are correct. The basic case is in fact correctly supported on your side. The issue is if you assign an ID (https://www.jenkins.io/doc/pipeline/steps/coverage/) to the Sorry for the bit of confusion that this caused. |
|
In light of the comment above, I'd be in favour of starting with this:
|
What
Closes #11689
Adds support for the new Jenkins Coverage Plugin (
io.jenkins.plugins.coverage) by extending the existingapiv4format with an optionalmetricquery parameter.Why
The
apiv4format previously only supportedlinecoverage. The new Jenkins Coverage Plugin exposes multiple metrics (branch,instruction,method,module,file) that users may want to display as badges.How
metricquery parameter toqueryParamSchema(valid values:line,branch,instruction,method,module,file, default:line)apiv4schema to accept all metrics as optional fieldsapiv4transform to use the selected metrichandlemethod to passmetricto transformExample