我正在使用Jenkins ver. 1.466和Jenkins Cobertura Plugin ver. 1.5。我为Django项目生成了覆盖率报告。所有的图表都很好,但是当我想查看源代码时,出现了警告信息:
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 run manage.py test --noinput
coverage xml -o ../reports/coverage.xml
我尝试使用:
sed 's/filename="/filename="my\/path\//g' coverage.xml > coverage2.xml
但是没有帮助,Cobertura插件无法找到相对或绝对路径下的源代码。
P.S. 如果我将源代码放入cobertura目录中,则会出现一些奇怪的问题-源代码会显示但不会高亮显示。
-r .
标志执行以下命令:coverage xml -r . -o ../reports/coverage.xml
。 - ULazdins