【问题标题】:Build step 'Execute shell' marked build as failure after timeout构建步骤“执行 shell”在超时后将构建标记为失败
【发布时间】:2019-12-01 22:52:31
【问题描述】:

我有这个命令:

php artisan config:clear
timeout 15 php artisan queue:work
php artisan queue:restart

作业失败:

+ php artisan config:clear
Configuration cache cleared!
+ timeout 5 php artisan queue:work
Build step 'Execute shell' marked build as failure
Finished: FAILURE

我需要在 15 秒后停止该命令 php artisan queue:work,这就是我使用 timeout 的原因。

为什么会出现这个错误?没有超时,一切正常。

【问题讨论】:

  • @Rob 为什么是重复的?在那个问题中,错误存在sudo: no tty present and no askpass program specified 在我的情况下,我只是有一个超时,然后它退出

标签: jenkins


【解决方案1】:

据此:https://www.howtoforge.com/linux-timeout-command/#q-how-to-get-commands-exit-status-in-output

timeout成功时的退出码是124。

由于脚本的退出代码不是 0(因为这是您运行的最后一个命令,或者因为您在脚本中使用了 set -e),Jenkins 将其视为失败。

由于您知道非 0 退出代码不是失败,您可以通过将您的命令传递给另一个始终以退出代码 0 退出的命令来解决此问题,例如:

timeout 5 php artisan queue:work | :

【讨论】:

    猜你喜欢
    • 2016-02-21
    • 2017-06-19
    • 2017-10-09
    • 2020-05-12
    • 2019-11-25
    • 2016-01-26
    • 1970-01-01
    • 2017-12-05
    • 1970-01-01
    相关资源
    最近更新 更多