8

我正在使用Jenkins 版本。1.466Jenkins Cobertura 插件版本。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 插件没有找到不具有相对或绝对路径的源代码。

PS 如果我将源代码放入cobertura目录会出现一些奇怪的问题 - 显示源代码但未突出显示。

4

3 回答 3

3

输出 xml 文件必须与coverage运行的文件夹位于同一文件夹中,因此:

coverage xml -o coverage.xml

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

于 2015-01-09T11:02:21.303 回答
1

您是否选中了“丢弃旧版本”或某种重新克隆并从头开始选项?如果没有,您可能需要查看存档工件并将您的覆盖文件添加到列表中。

于 2012-05-30T12:51:32.467 回答
0

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

我首先选择了Publish Coverage Report,但只Publish Cobertura Coverage Report允许访问文件内容。

于 2021-01-05T07:40:32.597 回答