Is there a better way to start a capistrano task due to a rake?

I have a rake task set where I need to call capistrano at some point. Edwin Goei blog suggests trimming the capistrano via "sh".

Is there an easier way? It would seem that you should be able to program the appropriate tasks. Thanks in advance.

+4
source share
3 answers

Yes, Capistrano has programmatic access to command line components. However, if you want to call them from the rake task, you need to do a little extra work.

task :deploy require 'rubygems' require 'capistrano' require 'capistrano/cli' parameters = ["deploy"] # this is an array of the strings that come after # cap on the command line. eg, # ["deploy", "-S", "revision=1024"] gives you local var # revision in your deploy.rb. # The following is required ONLY when you run Capistrano 2+ from Rake, # because Rake adds the methods from FileUtils to Object. FileUtils includes # a method called symlink which interferes with Capistrano symlink task. Capistrano::Configuration::Namespaces::Namespace.class_eval { undef :symlink } Capistrano::CLI.parse(parameters).execute! end 
+7
source

For capistrano 3:

http://capistranorb.com/documentation/advanced-features/capistrano-pure-ruby/

 require 'capistrano/all' stages = "production" set :application, 'my_app_name' set :repo_url, ' git@github.com :capistrano/capistrano.git' set :deploy_to, '/var/www/' set :stage, :production role :app, %w{} require 'capistrano/setup' require 'capistrano/deploy' Dir.glob('capistrano/tasks/*.cap').each { |r| import r } Capistrano::Application.invoke("production") Capistrano::Application.invoke("deploy") 
+3
source

Jonathan, your mileage may change if you do something like set (: shell, false) to stop the capistrano tasks in the sub-sh-shell.

Just think, feel free to ping me if you need a hand.

-1
source

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


All Articles