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

时间:2012-05-30 11:43:12

标签: django continuous-integration jenkins code-coverage cobertura

我正在使用 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 目录中会出现一些奇怪的问题 - 源代码会显示但不会突出显示。

3 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:1)

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

coverage xml -o coverage.xml

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

答案 2 :(得分:0)

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

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