4

我正在使用Jenkins ver。 1.466Jenkins Cobertura Plugin ver。 1.5。我为Django项目生成了覆盖率报告。所有图表看起来不错,但是当我想看看源代码,我必须警告消息:Jenkins Cobertura插件“源代码不可用”

coverage run manage.py test --noinput 
coverage xml -o ../reports/coverage.xml 

我试着使用:

sed 's/filename="/filename="my\/path\//g' coverage.xml > coverage2.xml 
使用以下步骤生成

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. 

覆盖率报告

但没有帮助,Cobertura插件没有找到相对或绝对路径的源代码。

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

+0

试着用'-r .'标志'coverage xml -r执行命令。 -o ../ reports/coverage.xml' – ULazdins

+0

这对Jenkins来说不适用于我。我尝试了一个绝对路径到我的源代码,并且它不起作用。我在github.com/gotwarlost/istanbul/issues/50上读到该路径应该与Jenkins工作区Cobdura目录相关。我尝试过,并相对于工作区目录,但都没有工作。谁能帮忙? – Mawg

回答

1

您是否已选中“放弃旧版本”或某种类型的重新生成并从头开始选项?如果没有,您可能需要查看归档工件并将您的覆盖率文件添加到列表中。

+0

选中“丢弃旧版本”,并设置“最大版本数量”1。 – Adin

1

输出XML文件必须在相同的文件夹,其中coverage运行,所以:

coverage xml -o coverage.xml 

到源文件夹的参考放入coverage.xml并且如果所述输出文件被放入另一个文件夹,对源文件夹的引用将不正确。

相关问题