Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Cobertura plugin "Source code is unavailable"

I'm using Jenkins ver. 1.466 with Jenkins Cobertura Plugin ver. 1.5. I generated coverage report for Django project. All charts looks good, but when I want to see source code I have warning message:

Source code is unavailable. Some possible reasons are:
    This is not the most recent build (to save on disk space, this plugin only keepsthe     most recent builds source code).
    Cobertura found the source code but did not provide enough information to locate the source code.
    Cobertura could not find the source code, so this plugin has no hope of finding it.

Coverage report is generated using these steps:

coverage run manage.py test --noinput
coverage xml -o ../reports/coverage.xml

I tried to use:

sed 's/filename="/filename="my\/path\//g' coverage.xml > coverage2.xml

but didn't help, Cobertura plugin didn't find source code not with relative or absolute path.

P.S. Some strange issue if I put source code into the cobertura directory - source code is displayed but not highlighted.

like image 892
Adin Avatar asked May 30 '12 11:05

Adin


People also ask

How do I get Jenkins code coverage?

If you click on the Coverage Report icon, you will see code coverage for each package in your application, and even drill down to see the code coverage (or lack thereof) for an individual class (see Figure 2.31, “Jenkins lets you display code coverage metrics for packages and classes”).

How do I generate a coverage report in cobertura?

start test in web interface ( by default localhost:9000/@tests) and go to your_host:your_port/@cobertura ( by default it's http://localhost:9000/@cobertura ) for generate new report or reset previous. And now you can see html report in iframe or directly on file:/path/to/your/application/test-result/code-coverage/.


1 Answers

The output xml file has to be in the same folder as where coverage is run, so:

coverage xml -o coverage.xml

The reference to the source folder is put into coverage.xml and if the output file is put into another folder, the reference to the source folder will be incorrect.

like image 191
Berend Klein Haneveld Avatar answered Nov 09 '22 05:11

Berend Klein Haneveld