Jenkins编译器警告插件未显示C或C ++源代码

时间:2015-10-26 14:00:11

标签: jenkins

我的构建脚本包含

  

打扫干净   全部

make调用gcc:

gcc --version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

我的构建后步骤是,"扫描编译器警告"我为GNU C Compiler 4 (gcc)选择了解析器。

这够了吗?我错过了什么吗?

我的控制台日志显示

[WARNINGS] Parsing warnings in console log with parser GNU C Compiler 4 (gcc)
[WARNINGS] Computing warning deltas based on reference build #72

当我点击编译器警告图表并向下钻取到单个源文件时,我得到

Copying the source file '../software_under_test/maths.c' from the workspace to the build folder '8410a4f3.tmp' on the Jenkins master failed.
02 Seems that the path is relative, however an absolute path is required when copying the sources.
03 Is the file 'maths.c' contained more than once in your workspace?
04 Is the file '../software_under_test/maths.c' a valid filename?
05 If you are building on a slave: please check if the file is accessible under '$JENKINS_HOME/[job-name]/../software_under_test/maths.c'
06 If you are building on the master: please check if the file is accessible under '$JENKINS_HOME/[job-name]/workspace/../software_under_test/maths.c'
07 java.io.IOException: Failed to copy ../software_under_test/maths.c to /home/mawg/.jenkins/jobs/plain_C_project/builds/73/workspace-files/8410a4f3.tmp
08   at hudson.FilePath.copyTo(FilePath.java:1991)
09   at hudson.plugins.analysis.util.Files.copyFilesWithAnnotationsToBuildFolder(Files.java:80)
10   at hudson.plugins.analysis.core.HealthAwareRecorder.copyFilesWithAnnotationsToBuildFolder(HealthAwareRecorder.java:312)
11   at hudson.plugins.analysis.core.HealthAwarePublisher.perform(HealthAwarePublisher.java:89)
12   at hudson.plugins.analysis.core.HealthAwareRecorder.perform(HealthAwareRecorder.java:259)
13   at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:75)
14   at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
15   at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
16   at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
17   at hudson.model.Build$BuildExecution.post2(Build.java:185)
18   at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
19   at hudson.model.Run.execute(Run.java:1766)
20   at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
21   at hudson.model.ResourceController.execute(ResourceController.java:98)
22   at hudson.model.Executor.run(Executor.java:408)
23 Caused by: java.io.FileNotFoundException: ../software_under_test/maths.c (No such file or directory)
24   at java.io.FileInputStream.open(Native Method)
25   at java.io.FileInputStream.<init>(FileInputStream.java:146)
26   at hudson.FilePath$41.invoke(FilePath.java:2017)
27   at hudson.FilePath$41.invoke(FilePath.java:2012)
28   at hudson.FilePath.act(FilePath.java:991)
29   at hudson.FilePath.act(FilePath.java:969)
30   at hudson.FilePath.copyTo(FilePath.java:2012)
31   at hudson.FilePath.copyTo(FilePath.java:1986)
32   ... 14 more

我做错了什么?

This page表示代码正在查找字符串&#34;输入目录&#34;在构建输出中,the code验证了这一点。

我调整了make步骤,通过将--print-directory添加到make命令并输出

来输出
+ make all --print-directory
make: Entering directory `/home/mawg/workspace/unit_test_C_code_example_project/Debug'
Building file: ../test_scripts/test_maths.c
Invoking: GCC C Compiler
gcc -DUNIT_TEST -I"/home/mawg/workspace/unit_test_C_code_example_project/mocks" -I"/home/mawg/workspace/unit_test_C_code_example_project/software_under_test" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"test_scripts/test_maths.d" -MT"test_scripts/test_maths.d" -o "test_scripts/test_maths.o" "../test_scripts/test_maths.c"
Finished building: ../test_scripts/test_maths.c

等,但这没有帮助。

那么,任何人都可以告诉我如何配置东西,以便深入研究Jenkins编译器警告插件的源代码吗?

3 个答案:

答案 0 :(得分:2)

这是我遇到此问题时的第一个结果,但此后我发现,至少在2018-07年之前,有一个“解析相对路径”的高级设置(不确定何时添加此路径),但是这为我解决了同样的问题

更新: 在Jenkins中添加了扫描编译器警告“生成后”操作后,将出现一个“高级”按钮。

Jenkins Warning plugin "Post Build" action main view

单击高级后,将显示选项列表。在此列表的下方,有一个标题为解决相对路径的部分,单击此按钮可以解决我的问题。

*Resolve relative paths* option in the Advanced setting section

这是在警告插件版本4.66中

答案 1 :(得分:1)

解决!

我遇到了同样的问题,并在跟踪更改后将其删除:

  1. 我设置了源代码管理 - &gt;本地模块目录 结账项目文件夹之后的一段时间,即“./ project1” 我之前没有“./”。
  2. 我还在make命令中添加了Option --print-directory。
  3. 现在它按预期工作了!

答案 2 :(得分:0)

好的,解决了!

问题是Eclipse生成的makefile包含相对路径。相对于它的makefile目录,但Jenkins编译器警告插件将其视为相对于Jenkins工作区。

解决方案是编辑makeilfe。对手动创建的makefile执行一次。如果您使用Eclipse,它会不断重新生成makefile,因此诀窍是编辑Jenkins shell脚本,以便在构建之前立即更改makefile。

请注意,我只更改了Test Under Test目录下的makefile。我对Google Test等中的编译器警告不感兴趣

所以,现在我的Jenkins shell脚本启动了

cd /home/mawg/workspace/unit_test_C_code_example_project/Debug

# Tweak the makefile to use an absolute path to the Software Under Test.
# If we use a relative path then the Jenkins comiler wanrings plugin
# cannot find the source code to display it, so that we can drill down
# into it and see the compiler warnings in situ.
sed 's|\.\./software_under_test/maths.c|/home/mawg/workspace/unit_test_C_code_example_project/software_under_test/maths.c|g' /home/mawg/workspace/unit_test_C_code_example_project/Debug/software_under_test/subdir.mk > /home/mawg/workspace/unit_test_C_code_example_project/Debug/software_under_test/subdir.mk.absolute
rm software_under_test/subdir.mk
mv software_under_test/subdir.mk.absolute software_under_test/subdir.mk

make clean
# The --print-directory option is required for the compiler warning plugin
make all --print-directory