Capistrano 3: How can I suppress the conclusion of a condition?

I created a Capistrano task to execute the rake command. I plan to redirect the output (STDOUT) to a file. For instance.

cap production invoke:rake TASK=mytask > out

This works, but my conclusion includes some additional Capistrano status output, for example.

00:00 invoke:rake 01 $HOME/.rbenv/bin/rbenv exec bundle exec rake mytask ... ✔ 01 ubuntu@mydomain.com 11.399s

Is there any way to suppress this?

+4
source share
2 answers

This is probably the output of stderr. If so, you can redirect the standard error to the standard, for example:

cap production invoke:rake TASK=mytask > out 2>&1
0
source

Good, so I think I found a pretty good solution.

( Capistrano 3.x, ). https://github.com/capistrano/capistrano-2.x-docs/blob/master/2.x-DSL-Action-Inspection-Capture.md

namespace :invoke do
  desc "Execute a rake task on a remote server"
  task :rake do
    if ENV['TASK']
      on roles(:app) do
        with rails_env: fetch(:rails_env) do
          puts capture :rake, ENV['TASK']
        end
      end
    else
      puts "\n\nFailed! You need to specify the 'TASK' parameter!",
          "Usage: cap <stage> invoke:rake TASK=your:task"
    end
  end
end
0

Source: https://habr.com/ru/post/1684003/


All Articles