8

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.

braindamage
  • 2,226
  • 4
  • 24
  • 33

1 Answers1

7

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

Tim Ramsey
  • 987
  • 13
  • 24