Friday, March 25, 2016

Capistrano doesn't abort deployment when task fails

Leave a Comment

Capistrano doesn't abort when the executed commands exit status is different than 0. And continues to deployment. How can I abort the deployment when the executed command fails, returns an exit status different than 0?

I tried test, execute, capture commands but couldn't make it happened. Here is the recent code that I am testing failure, I actually running real jobs. When I try to execute in on the remote server, the exit status is 1.

   desc "Command to abort"    task :aborting_command do       on roles(:all) do |host|             within release_path do                execute("false")             end          end       end    end 

Output of it:

INFO [0ea66341] Running /usr/bin/env false on remote-server.xxx DEBUG [0ea66341] Command: cd /projectdir/releases/20160315140516 && /usr/bin/env false INFO [0ea66341] Finished in 0.044 seconds with exit status 0 (successful). 

With --trace:

** Invoke deploy:aborting_command (first_time) ** Execute deploy:aborting_command DEBUG [d5f30008] Running /usr/bin/env if test ! -d /projectdir/releases/20160315140254; then echo "Directory does not exist '/projectdir/releases/20160315140254'" 1>&2; false; fi on remote-server.xxx DEBUG [d5f30008] Command: if test ! -d /projectdir/releases/20160315140254; then echo "Directory does not exist '/projectdir/releases/20160315140254'" 1>&2; false; fi DEBUG [d5f30008] Finished in 0.042 seconds with exit status 0 (successful). INFO [50a2e035] Running /usr/bin/env false on remote-server.xxx DEBUG [50a2e035] Command: cd /projectdir INFO [50a2e035] Finished in 0.043 seconds with exit status 0 (successful). 

Working on with Capistrano Version: 3.4.0 (Rake Version: 10.4.2)

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment