Jenkins Cobertura插件“源代码不可用”

8
我正在使用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
这对我在Jenkins上不起作用。我尝试了一个绝对路径到我的源代码,但它没有起作用。我在github.com/gotwarlost/istanbul/issues/50上读到,路径应该相对于Jenkins工作区Cobdura目录。我尝试了相对于工作区目录的路径,但都没有起作用。有人能帮忙吗? - Mawg says reinstate Monica
3个回答

3
输出的XML文件必须与运行coverage命令的文件夹位于同一目录中,因此:
coverage xml -o coverage.xml

将源文件夹的引用放入coverage.xml中,如果输出文件放在另一个文件夹中,则源文件夹的引用将不正确。


这对我们起作用了 - 我正在将覆盖文件复制到子文件夹中,运行 coverage combine,然后将报告输出回父文件夹。一定是搞错了所有相对路径。 - jon_two

1
你是否勾选了“丢弃旧构建”或者其他重新克隆并从头开始的选项?如果没有,你可能需要考虑将构建产物存档,并将覆盖率文件添加到列表中。

“Discard Old Builds” 已被勾选,且 “保留的最大版本数” 被设置为 1。 - Adin

0

我曾经遇到过同样的问题(源代码不可用),尽管我的 .xml 文件放在了正确的位置。这只是因为我在 Jenkins 中选择了错误的后构建操作。

我最初选择了 发布覆盖率报告,但只有 发布 Cobertura 覆盖率报告 才能访问文件内容。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接