当执行的命令退出状态不为0时,Capistrano不会中止。并继续部署。如何在执行的命令失败时中止部署,返回不同于0的退出状态?
我尝试过测试,执行,捕获命令但却无法实现。这是我最近测试失败的代码,我实际上正在运行真正的工作。当我尝试在远程服务器上执行时,退出状态为1.
desc "Command to abort"
task :aborting_command do
on roles(:all) do |host|
within release_path do
execute("false")
end
end
end
end
输出:
INFO [0ea66341] Running /usr/bin/env false on remote-server.xxx
DEBUG [0ea66341] Command: cd /projectdir/releases/20160315140516 && /usr/bin/env false
INFO [0ea66341] Finished in 0.044 seconds with exit status 0 (successful).
使用--trace:
** Invoke deploy:aborting_command (first_time)
** Execute deploy:aborting_command
DEBUG [d5f30008] Running /usr/bin/env if test ! -d /projectdir/releases/20160315140254; then echo "Directory does not exist '/projectdir/releases/20160315140254'" 1>&2; false; fi on remote-server.xxx
DEBUG [d5f30008] Command: if test ! -d /projectdir/releases/20160315140254; then echo "Directory does not exist '/projectdir/releases/20160315140254'" 1>&2; false; fi
DEBUG [d5f30008] Finished in 0.042 seconds with exit status 0 (successful).
INFO [50a2e035] Running /usr/bin/env false on remote-server.xxx
DEBUG [50a2e035] Command: cd /projectdir
INFO [50a2e035] Finished in 0.043 seconds with exit status 0 (successful).
使用Capistrano版本:3.4.0(耙版:10.4.2)