问题
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)?
回答1:
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
Using this
回答2:
Generally in shell you can run multiple commands the way you want by command1 --some-argument foo && command2 && command3. the && operator will cause, that the chain will stop when one command fails (returns non-zero return value).
来源:https://stackoverflow.com/questions/9625622/capistrano-run-local-command-exit-on-failure