douweng1935 2014-11-05 09:47
浏览 56
已采纳

中止构建php警告/错误

We have several php scripts wrapped with other non-php commands in a single shell script, like this:

build_stuff.sh

mv things stuff
cp files folders
composer install
php bin/console some:command
php bin/console some:other:command

This shell script is then called in a "execute shell" build step.

sh ./build_stuff.sh

Is there any possibility to abort the build as "failure", as soon as there are php errors/warnings?

So that the next command wouldn't be executed.
And still maintain all commands in one script.

...

I found the Log Parser Plugin, but i would like to abort when the errors occur, not continue and parse the logs afterwards.

I though about maybe catching the PHP exit codes, as described here:
Retrieve exit status from php script inside of shell script

But you wouldn't be able to instantly see text output of the php scripts then, would you?

  • 写回答

1条回答 默认 最新

  • douping3427 2014-11-05 10:08
    关注

    Combining them with double ampersands will do the job. In the below example cmd2 will be executed only if cmd1 succeeds (returns a zero exit status).

    cmd1 && cmd2
    

    It will work with composer; but your commands might need modification to send proper exit codes.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料