shell - 运行 shell 脚本时如何在 Jenkins 中将构建标记为不稳定

在我正在进行的一个项目中,我们使用 shell 脚本来执行不同的任务。有些是运行 rsync 的 sh/bash 脚本,有些是 PHP 脚本。其中一个 PHP 脚本正在运行一些集成测试,这些测试输出到 JUnit XML、代码覆盖率报告等。

Jenkins 能够根据 exit status 将作业标记为成功/失败。在 PHP 中,如果脚本在运行期间检测到测试失败,则脚本以 1 退出。其他 shell 脚本运行命令并使用其中的退出代码将构建标记为失败。

// :: End of PHP script:
// If any tests have failed, fail the build
if ($build_error) exit(1);

在 Jenkins Terminology ,不稳定的构建被定义为:

A build is unstable if it was built successfully and one or more publishers report it unstable. For example if the JUnit publisher is configured and a test fails then the build will be marked unstable.

如何让 Jenkins 在运行 shell 脚本时将构建标记为不稳定,而不仅仅是成功/失败?

最佳答案

现代 Jenkins 版本(自 2016 年 10 月 2.26 起)解决了这个问题:它只是执行 shell 构建步骤的一个高级选项!

您可以选择并设置任意退出值;如果匹配,则构建将不稳定。只需选择一个不太可能由您的构建中的实际进程启动的值。

https://stackoverflow.com/questions/8148122/

相关文章:

php - 错误构建 : fatal error: pcre. h:没有这样的文件或目录

python - MANIFEST.in 在 "python setup.py install"上被

unit-testing - 没有找到测试。确保已安装的测试发现器和执行器、平台和框架版本设置正确,

go - go build 是什么意思? (去构建与去安装)

testing - Gradle 测试依赖

visual-studio-2010 - 在每次编译时禁用 "output window"的显示

jenkins - 使用 ‘H * * * *’ 而不是 ‘5 * * * *’ 均匀分布负载

android - 错误 - Android 资源链接失败(AAPT2 27.0.3 Daemon

testing - 如何在不从命令行测试的情况下运行 sbt 汇编命令?

java - .NET 世界是否有 Maven 替代方案或端口?