Capistrano & Bash: ignore command exit status

nicholaides picture nicholaides · Apr 17, 2009 · Viewed 22.4k times · Source

I'm using Capistrano run a remote task. My task looks like this:

task :my_task do
  run "my_command"
end

My problem is that if my_command has an exit status != 0, then Capistrano considers it failed and exits. How can I make capistrano keep going when exit when the exit status is not 0? I've changed my_command to my_command;echo and it works but it feels like a hack.

Answer

mthorley picture mthorley · Aug 25, 2009

The simplest way is to just append true to the end of your command.

  task :my_task do
    run "my_command"
  end

Becomes

  task :my_task do
    run "my_command; true"
  end