Question

I using Capistrano 3 and need to run rvmrc trust command to deploy.

I added this code to my deploy.rb

namespace :rvm do
  task :trust do
   execute :rvm, "rvmrc trust #{fetch(:current_release)}"
  end
end

after 'deploy:updated', 'rvm:trust'

But the task doesn't execute.

How to execute rvmrc trust using Capistrano 3?

Is there any way to see deploy tasks flow before running cap deploy task?

Thank you!

Était-ce utile?

La solution

Finally I got it how to do it. The problem was that using release_path it returns the current path, the symlink and not the actual path. So I got to that searching the internet.

# file: lib/capistrano/tasks/rvmrc.cap
namespace :rvmrc do
  desc "Trust rvmrc file" 
  task :trust do
      on roles(:app) do
        releases = capture("ls #{File.join(fetch(:deploy_to), 'releases')}")
      if this_host_last_release = releases.split("\n").sort.last
          execute "~/.rvm/bin/rvm rvmrc trust #{releases_path}/#{this_host_last_release}"
      end
    end
  end
end

# file: deploy.rb, in the end
after :finishing, 'rvmrc:trust'

Autres conseils

Updated solution for capistrano-3.4.0:

# file: lib/capistrano/tasks/rvmrc.rake
namespace :rvmrc do
  desc "Trust rvmrc file" 
  task :trust do
    on roles(:all) do
      command = "rvmrc trust #{release_path}/#{fetch(:current_revision)}"
      execute :rvm, command
    end
  end
end
before 'deploy:set_current_revision', 'rvmrc:trust'
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top