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?
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.