I am using cobertura plugin in jenkins for code coverage. I want to change value of name column in Project Coverage summary on a per-report basis.
Is there any way to change this. I want to give my project name over there.
I am using cobertura plugin in jenkins for code coverage. I want to change value of name column in Project Coverage summary on a per-report basis.
Is there any way to change this. I want to give my project name over there.
Here is a fork of the plugin that does what you are asking (project name instead of "cobertura coverage report").
https://github.com/andytompkins/cobertura-plugin
Right now it just uses the project name. I suppose this could become a configurable item? I'll be glad to work on it more if something else is needed, and could probably even package the changes up in a way that upstream will take them.
The relevant code that was changed was in CoverageResult.java. Added a method:
public String getJobName() {
AbstractProject job = owner.getProject();
return job.getName();
}
And in the index.jelly changed the reference from it.name to it.getJobName().
<td>${it.getJobName()}</td>
It will be a bit harder to make it on a per-report basis. The report itself does not have a name or title field - and this plugin does not control the format, it just reads it.
I too am using this with a javascript project that uses karma and karma-coverage. Currently running the forked plugin in production jenkins.
EDIT: In the branch use-filename-for-reportname in my repo you will find a version of the plugin that will use the coverage file's name as the report name.
I suggest going to the plugin page, contacting one of the maintainers:
Stephen Connolly (id: stephenconnolly)
Manuel Carrasco Monino (id: manuel_carrasco)
Seiji Sogabe (id: ssogabe)
And asking them how you can do it.
Once you have the solution, share it here, because others (like me) might also want this capability...
I hope this helps.
You can go to the plugin Github page, and clone a copy of the source code for yourself.
A quick search reveals that the line you want to change is probably located in this file:
src/main/resources/hudson/plugins/cobertura/Messages.properties
CoberturaCoverageParser.name=Cobertura Coverage Report
Change that line to what you want. Save and rebuild the plugin. There is a big tutorial on how to build Jenkins plugins here.
Well I only used Cobertura once in Maven and there you can choose between a xml and html output, which is created in the outputDirectory you define in your project's pom.xml file.
Supposing that the logic is the same you could go to the generated xml or html files and simply search for the string "Cobertura Coverage Report" and changing it there.
This will work if the objective of changing it is to send to someone (for example: a report to your boss).
As far as I see it's not possible, for now, to change some config and have a definite solution.
What I'd suggest is, to open a issue at the plugin page or even at their OpenSource Repository at GitHub and propose the enhancement or even contribute yourself.
If that doesn't make them move I'd suggest trying to contact the maintainers at the plugin page.
The solution you're looking for is not available, Cobertura doesn't support it. The Cobertura plugin will show always that same report structure where the overall report summary will always have the value "cobertura coverage report", the Emma coverage plugin who is very similar has on that same spot the string value "all packages", unless you edit the source code or ask for an enhancement, sorry.
In case you opt to change the source code, it's indeed the value suggested by Slav:
src/main/resources/hudson/plugins/cobertura/Messages.properties
CoberturaCoverageParser.name=Cobertura Coverage Report
But in this case you'd have to create and install a new plugin for each project you'd have.
So at the bottom-line I wouldn't go in that direction. On the other hand, what I'd suggest is using Cobertura or Karma (in Daniel Schaffer's case) to generate html instead. This one can easily be altered with basic html and css skills to have your desired look and feel.
© 2022 - 2024 — McMap. All rights reserved.