本文介绍了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在失败时运行本地命令退出
发布评论