Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano run local command exit on failure

Tags:

capistrano

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)?

like image 623
jadent Avatar asked Feb 21 '26 22:02

jadent


1 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

like image 57
Federico Avatar answered Feb 27 '26 08:02

Federico



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!