在 hudson 中设置一个测试构建作业来检测 make 何时无法编译

发布于 2024-10-06 03:56:57 字数 567 浏览 5 评论 0原文

我在 hudson 中建立了一个“自由风格项目”,它从 svn 存储库中检查我的源代码。然后我添加了一个“shell 步骤”来构建代码:

echo "# $JOB_NAME: $BUILD_ID" >log
cd to/my/path/
qmake &>>$WORKSPACE/log
make &>>$WORKSPACE/log

运行测试后,hudson 说成功了。当我查看构建的控制台输出时,我发现:

In file included from src/tut.h:47,
                 from src/tut3module.cpp:1:
src/log.h:69: error: ‘uint8_t’ has not been declared
make: *** [obj/tut3module.o] Fehler 1
Finished: SUCCESS

为什么 hudson 无法识别此错误?我必须如何配置该作业?

如果您需要有关我的配置的更多信息,请告诉我!

感谢您的帮助!

I have set up a 'freestyle project' in hudson that checks my source-code out from a svn repository. Then I added a 'shell step' to build the code:

echo "# $JOB_NAME: $BUILD_ID" >log
cd to/my/path/
qmake &>>$WORKSPACE/log
make &>>$WORKSPACE/log

After running a test, hudson says t succeeded. When I look into the console output of the build I find:

In file included from src/tut.h:47,
                 from src/tut3module.cpp:1:
src/log.h:69: error: ‘uint8_t’ has not been declared
make: *** [obj/tut3module.o] Fehler 1
Finished: SUCCESS

Why does hudson not recognize this error? How do I have to configure the job?

Let me know if you need more information about my configuration!

Thanks for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

握住我的手 2024-10-13 03:56:57

Hudson 使用构建步骤的错误代码来确定构建步骤是成功还是失败。您的整个构建步骤将转换为一个脚本。如果您不在脚本中的某个位置调用 exit,则脚本的 last 命令的退出代码将成为脚本的退出代码。

请参阅以下脚本

copy readme.txt dd:
type readme.txt

让我们假设 readme.txt 存在。复制将失败,错误代码为 1,因为 dd: 是未知设备。 type 命令将成功,因此构建步骤本身将返回成功。因此,要么将构建命令分开,要么在每个命令后检查错误代码。系统管理员向我推荐了第三种方法:运行脚本并检查结果。因此,就您而言,只要您的构建工件存在,您的构建就应该可以正常工作。

当然,您也可以使用 sagar 提到的日志解析器插件。但是,如果可以避免它,请使用检查错误代码的脚本,然后依赖日志解析器。顺便说一句,有些命令偏离标准并返回非零错误代码,即使在成功的情况下也是如此。

Hudson uses the error code of the build step to determine if the build step was successful or failed. Your whole build step will be converted to one script. If you don't call exit somewhere in the script the exit code of last command of the script becomes the exit code of the script.

See following script

copy readme.txt dd:
type readme.txt

Let's assume that readme.txt exists. The copy will fail with errorcode 1, because dd: is an unknown device. The type command will succeed and therefore the build step itself will return a success. So either separate the build commands or check the error code after each command. A SysAdmin recommended a third approach to me: Run your script and check the results. So in your case, your build should have worked whenever your build artifacts exists.

Of course you can also use the log parser plugin as mentioned by sagar. But if you can avoid it, go with script that checks for error codes rather, then to rely on the log parser. BTW, there are commands that deviate from the standard and return a non-zero error code, even in a success case.

陌伤浅笑 2024-10-13 03:56:57

Hudson 没有识别出错误,可能是因为在构建步骤中,您将 qmake 和 make 的 stdout 和 stderr 重定向到日志:

qmake &>>$WORKSPACE/log
make &>>$WORKSPACE/log

尝试删除重定向并查看是否会改变。所以:

echo "# $JOB_NAME: $BUILD_ID" >log
cd to/my/path/
qmake
make

无论如何,你有第二个选择:

你可以使用这个:
http://wiki.hudson-ci.org/display/HUDSON/Log +Parser+Plugin

您可以将其设置为识别“错误”和“失败”等单词,并导致构建失败。
它使用正则表达式来检测单词,因此您可以很好地控制它用于检测故障的内容。

Hudson is not recognising the error probably because, in your build step, you are redirecting both the stdout and stderr for qmake and make to a log:

qmake &>>$WORKSPACE/log
make &>>$WORKSPACE/log

Try removing the redirects and see if that changes things. So:

echo "# $JOB_NAME: $BUILD_ID" >log
cd to/my/path/
qmake
make

In any case, you have a second option:

You could use this:
http://wiki.hudson-ci.org/display/HUDSON/Log+Parser+Plugin

You can set it up to recognize words like 'error' and 'failed' and cause it to fail the build.
It uses regex to detect words, so you have a lot of control over what it uses to detect the failure.

日久见人心 2024-10-13 03:56:57

尝试在 hudson 中创建两个单独的构建步骤。第一步是编译。第二步运行这些步骤。如果这些步骤中的任何一个失败,哈德森都应该失败。

Try creating two separate build steps in hudson. Make the first step be the compile. the second step runs the steps. If any of those steps fail hudson should fail.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文