Laravel Envoy显示错误但不显示环境

时间:2017-12-20 16:00:19

标签: php laravel laravel-5 laravel-5.5 laravel-envoy

我和Laravel Envoy有问题。 我写了用于在服务器上部署的脚本,我用 envoy run deploy --environment = staging 来调用该脚本但是当出现错误时,我看不到从什么生产是错误的。 例如,php artisan migrate发生错误,我可以捕获发生错误的任务但我无法获得环境。 这是我的代码:

@error

@slack('hook', '#deploy', "Deploy failed on {$environment} error: 
$task")
exit;
@enderror

松弛频道部署的输出是:
错误时部署失败:migrate-db

1 个答案:

答案 0 :(得分:1)

听起来你的Envoy脚本在migrate-db任务中有错误。如果不发布代码,就很难分辨出该任务发生了什么。我建议在任务中使用简单的echo来首先完成脚本。

运行envoy run deploy --env=staging

@servers(['web' => '127.0.0.1'])

@setup
    $env  = isset($env) ? $env : "localhost";
    $host = gethostname();
    $hook =  "https://hooks.slack.com/services/XXX";
    $channel = "#your-channel";
@endsetup

@story('deploy')
    migrate-db
@endstory

@task('migrate-db')
    echo 'migrate-db'
@endtask

@error
    @slack($hook, $channel, "Deploy failed on [$env], hostname: $host");
    echo "Deploy failed on [$env], hostname: $host\r\n";
@enderror

@finished
    @slack($hook, $channel, "Deploy succeeded on [$env], hostname: $host");
    echo "Deploy succeeded on [$env], hostname: $host\r\n";
@endfinished