Capistrano deploy fails after I changed the repository URL

前端 未结 10 700
野性不改
野性不改 2021-01-30 01:24

I have a simple deployment via capistrano from a Git repository. At first I was deploying form GitHub, everything worked just fine. But then I moved my repository to BitBucket a

相关标签:
10条回答
  • 2021-01-30 02:04

    I solved this with the following in deploy.rb:

    namespace :deploy do
      task :cope_with_git_repo_relocation do
        run "if [ -d #{shared_path}/cached-copy ]; then cd #{shared_path}/cached-copy && git remote set-url origin #{repository}; else true; fi"
      end
    end
    before "deploy:update_code", "deploy:cope_with_git_repo_relocation"
    

    It makes deploys a little slower, so it's worth removing once you're comfortable that all your deploy targets have caught up.

    0 讨论(0)
  • 2021-01-30 02:08

    For Capistrano 3.0+

    1. Change the repository URL in your config/deploy.rb

    2. Change the repository URL in the your_project/repo/config file on the server.

    0 讨论(0)
  • 2021-01-30 02:14

    If you need to do a lot of repo's you might want to add a task for it.

    For capistrano 3 you add this task in your deploy.rb

    desc "remove remote git cache repository"
      task :remove_git_cache_repo do
          on roles(:all) do
        execute "cd #{fetch(:deploy_to)} && rm -Rf repo"
      end
    end
    

    And then run it once for every stage:

    cap testing remove_git_cache_repo
    
    0 讨论(0)
  • 2021-01-30 02:15

    I gotta say I’m not sure, since I haven’t been able to test this but this should work:

    cap deploy:cleanup -s keep_releases=0
    

    Since it wipes every release (cache) from the server.

    Apparently you will also need to remove shared/cached-copy, because this doesn’t seem to be cleaned by the Capistrano call above according to the comment below.

    0 讨论(0)
提交回复
热议问题