Capistrano在失败时运行本地命令退出 [英] Capistrano run local command exit on failure
本文介绍了Capistrano在失败时运行本地命令退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想运行本地命令并在任何命令失败时退出。 Capistrano最好的方法是什么? run_locally将继续失败。
I would like to run local commands and exit on failure of any command. whats the best way to do this with capistrano? run_locally will continue going on failure.
我是否每次都要检查最后一个命令是否存在(或创建自定义的本地运行函数)?
Do i have to check the last commands exist status everytime (or create a custom run locally function)?
推荐答案
我必须创建自己的函数,如下所示:
I had to create my own function like this:
task :build_backend do
run_local("echo hello")
run_local("abcdef")
run_local("echo 'not run'")
end
def run_local(cmd)
system cmd
if($?.exitstatus != 0) then
puts 'exit code: ' + $?.exitstatus.to_s
exit
end
end
使用此
这篇关于Capistrano在失败时运行本地命令退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文