Jenkins Cobertura plugin "Source code is unavailable"
Asked Answered
U

3

9

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.

Uncanonical answered 30/5, 2012 at 11:43 Comment(2)
Try executing the command with -r . flag coverage xml -r . -o ../reports/coverage.xmlChill
This does not work for me, with Jenkins. I tried an absolute path to my source code, and that it not work. I read at github.com/gotwarlost/istanbul/issues/50 that the path should be relative to the Jenkins workspace Cobdura directory. I tried that and relative to the workspace directory, but neither worked. Can anyone help?Twedy
R
3

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.

Restrictive answered 9/1, 2015 at 11:2 Comment(1)
This worked for us - I was copying coverage files to a subfolder, running coverage combine, then outputting the report back to the parent folder. Must have messed up all the relative paths.Onofredo
E
1

Do you have "Discard Old Builds" checked or some kind of reclone and start from scratch option? If not you may want to look into archiving artifacts and add your coverage file to the list.

Epistaxis answered 30/5, 2012 at 12:51 Comment(1)
"Discard Old Builds" is checked and "Max # of builds to keep" is setted 1.Uncanonical
V
0

I had the same problem (source code unavailable) although my .xml was at the proper place. It was simply because I chose the wrong post-build action in Jenkins.

I first selected Publish Coverage Report, but only Publish Cobertura Coverage Report gives access to files content.

Vuillard answered 5/1, 2021 at 7:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.