Capistrano triggers local command output on failure

I would like to run local commands and crash any command. What's the best way to do this with capistrano? run_locally will continue to fail.

Do I need to check the latest states of the command every time (or create a custom local run function)?

+3


source to share


2 answers


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


source


Usually in the shell, you can run multiple commands as you want command1 --some-argument foo && command2 && command3

. the operator &&

will cause the chain to stop when one command fails (returns a nonzero return value).



0


source







All Articles