Capistrano deploy fails after I changed the repository URL

前端 未结 10 698
野性不改
野性不改 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 01:52

    Capistrano 2 and below

    SSH to your server and update the repo in ./shared/cached-copy/.git/config of the deployment folder, or just remove the ./shared/cached-copy

    Capistrano 3 and above

    SSH to your server and update the repo in ./repo/config of the deployment folder.

    Check Fixing Capistrano 3 deployments after a repository change

    0 讨论(0)
  • 2021-01-30 01:53

    Here's the Capistrano 3 version of what this answer talks about. It might be tedious to do what the answer suggests on each server.

    So drop this in deploy.rb and then run cap <environment> deploy:fix_repo_origin

    namespace :deploy do
      desc 'Fix repo origin, for use when changing git repo URLs'
      task :fix_repo_origin do
        on roles(:web) do
          within repo_path do
            execute(:git, "remote set-url origin #{repo_url}")
          end
        end
      end
    end
    
    0 讨论(0)
  • 2021-01-30 01:55

    Capistrano 2.X

    Delete and re-clone the repo using the new address:

    cd $deploy_to/shared
    rm -rf cached-copy
    git clone ssh://git@example.org/new/repo.git cached-copy
    

    Modify your config/deploy.rb to use the new repo:

    set :repository, "ssh://git@example.org/new/repo.git"
    set :scm, :git
    set :deploy_via, :remote_cache
    

    Deploy again:

    cap deploy
    

    Capistrano 3.X

    1. Remove the $deploy_to/repo directory
    2. Modify your config/deploy.rb (same as 2.X)
    3. cap deploy
    0 讨论(0)
  • 2021-01-30 01:56

    You need to change git origin in your /shared/cached-copy folder

    cd /var/www/your-project/production/shared/cached-copy
    git remote remove origin
    git remote add origin git@bitbucket.org:/origin.git
    

    try cap production deploy

    0 讨论(0)
  • 2021-01-30 01:56

    The most simple way is just changing the repo url to the new one in .git/config in the shared/cached-copy directory on the webserver. Then you can do a normal deploy as usual.

    0 讨论(0)
  • 2021-01-30 01:57

    Depends on your version Capistrano 3 is different from it's older ancestors:

    Read my original answer here and how to fix similar issues Capistrano error when change repository using git

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