kimon
kimon

Reputation: 2505

Coverage results via REST API

I'm trying to get coverage results from Jenkins using the REST API and the Cobertura plugin.

It looks like I can get the top level information about coverage results since the Cobertura plugin puts the bottom line results in the healthReport of the job.

However, I would like more detailed information about code coverage.

So I tried:

<jenkins url>/job/<job>/<buildNo>/cobertura/api/json

I get just empty results. I assume from this the Cobertura plugin just didn't implement the API for returning this information.

Is there another way to get this information programatically other than modifying the Cobertura plugin?

Upvotes: 6

Views: 4190

Answers (2)

kimon
kimon

Reputation: 2505

Turns out there is a jenkins plugin defect open on this. But the answer above is correct-- you can get most of the information by adding "depth" (coverage ratios).

However, unfortunately this still does not give all the information you get via html, namely the number of lines scanned in each module, it just gives you pct. This is much better than nothing, but still incomplete. I've annotated the defect to reflect this...

Upvotes: 1

sas
sas

Reputation: 7542

If you append "?depth=2" to your query, you'll get additional percentage info. Higher values for depth show the individual file coverage.

Upvotes: 11

Related Questions