ruby-on-railsdeploymentcapistranobitbucketrvm-capistrano

Issue with bitbucket repository to deploy rails app using capistrano


Getting github for bitbucket repository.

The authenticity of host 'github.com (some_ip_address)' can't be established.

This is my deploy file. deploy:setup and deploy:check are working perfectly.

require "bundler/capistrano" 
require "rvm/capistrano"

default_run_options[:pty] = true 
ssh_options[:forward_agent] = true

set :repository, 'ssh://git@bitbucket.org/username/repo.git' 
set :scm :git 
set :scm_verbose, true
set :user, 'root'
set :deploy_via, :remote_cache
set :migrate_target, :current
set :branch, 'master'
set :application, 'my_app_name' 
set :domain, 'my_domain_ip_address'
set :applicationdir, "/home/deploy/domains/#{application}"
set :deploy_to, "/home/deploy/domains/#{application}"
role :web, domain role :app, domain role :db,  domain, :primary => true
set :keep_releases, 5
set :rvm_type, :system

after 'deploy:restart', 'deploy:cleanup'

namespace :deploy do   
  task :start do ; end   
  task :stop do ; end   
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
    run "#{try_sudo} chmod 777 #{File.join(current_path,'tmp/')}"
    run "#{try_sudo} chmod 777 #{File.join(current_path,'log/')}"
  end
  task :after_deploy do
    run "cd #{current_path} && bundle install --deployment"
    run "cd #{current_path}; RAILS_ENV=#{rails_env} bundle exec rake db:migrate"
    run "#{try_sudo} chmod 777 -R #{current_path}/tmp/"
    run "#{try_sudo} chmod 777 -R #{current_path}/log/"
    run "#{try_sudo} chmod 777 . #{current_path}/log/"   
  end 
end

after 'deploy', 'deploy:after_deploy'

Note: I am trying to deploy rails app for first time.

Server: Digital Ocean VPS

Repository: bitbucket.org

I added ssh key of server in the bitbucket account.

Issue: While 'cap:deploy', after executing deploy,deploy:update,deploy:update_code,deploy:finalize_update,deploy:assets:symlink,

Getting issue at executing 'bundle install', It is asking for github authenticity, while am using bitbucket.


Solution

  • Try setting the git URL like this

    set :repository, 'git@bitbucket.org:username/repo.git'
    

    If you have not added your keys to bitbucket, you can do it here https://bitbucket.org/account/user/username/ssh-keys/