Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano & Bash: ignore command exit status

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.

like image 750
nicholaides Avatar asked Apr 17 '09 02:04

nicholaides


People also ask

What is the use of Capistrano?

Capistrano is a tool for deploying applications using deployment scripts. To perform deployments, you can use predefined tasks or create custom Rake tasks. RubyMine allows you to quickly run Capistrano tasks with double Ctrl and configure Capistrano run options using run configurations.

What is Capistrano Ruby?

Capistrano is a framework for building automated deployment scripts. Although Capistrano itself is written in Ruby, it can easily be used to deploy projects of any language or framework, be it Rails, Java, or PHP.

How do I run Capfile?

Navigate to your application's root directory in Terminal and run the following command: capify . This command creates a special file called Capfile in your project, and adds a template deployment recipe at config/deploy.

Is Capistrano free?

This book is available for free download in a number of formats - including epub, pdf, azw, mobi and more. You can also read the full text online using our ereader.


2 Answers

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 
like image 124
mthorley Avatar answered Oct 03 '22 00:10

mthorley


For Capistrano 3, you can (as suggested here) use the following:

execute "some_command.sh", raise_on_non_zero_exit: false
like image 42
Ciryon Avatar answered Oct 03 '22 01:10

Ciryon