Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Envoy: abort on error

Is it possible to abort on errors or call another task when a command fails?

This doesn't work:

@task('migrate', ['on' => 'web'])
    cd {{ $currentReleaseDir }};
    php artisan migrate || exit 1;
@endtask

It fails with the message (I know I can run --force, it's just a way to make the command fail for testing):

**************************************
*     Application In Production!     *
**************************************

But then it proceeds to run the rest of the deploy script.

like image 366
braindamage Avatar asked Nov 11 '15 19:11

braindamage


1 Answers

Yes, you can use:

@error
   echo $task;
   exit; /*Or Do any other processing*/
@enderror

this outputs

<?php $__container->error(function($task) {
    echo $task;
    exit; /*Or Do any other processing*/
}); ?>

This is listed in the compiler functions here https://github.com/laravel/envoy/blob/master/src/Compiler.php

like image 109
Tim Ramsey Avatar answered Nov 16 '22 04:11

Tim Ramsey