문제

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!

도움이 되었습니까?

해결책

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'

다른 팁

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'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top