Capistrano、プライベート bitbucket リポジトリ、および mercurial を使用して、コードを Amazon EC2 インスタンスにデプロイしようとしています。
cap deploy:setup
開発ボックスから正常に実行されました。
それから私は実行しようとしましたcap deploy:cold
。bitbucket のパスワードを入力するように求められましたが、これは正しく入力しましたが、「承認に失敗しました」というエラー メッセージが表示されました。その結果、コードをデプロイしようとしていたマシンは、bitbucket リポジトリからコードを「複製」できませんでした。
詳細は次のとおりです。
% cap deploy:cold
triggering load callbacks
* 2013-01-10 18:44:07 executing 'production'
triggering start callbacks for 'deploy:cold'
* 2013-01-10 18:44:07 executing 'multistage:ensure'
* 2013-01-10 18:44:07 executing 'deploy:cold'
* 2013-01-10 18:44:07 executing 'deploy:update'
** transaction: start
* 2013-01-10 18:44:07 executing 'deploy:update_code'
updating the cached checkout on all servers
executing locally: "hg log --verbose -r default --template \"{node|short}\""
command finished in 797ms
* executing "if -d /home/ec2-user/my_project/shared/cached-copy ; then hg pull --verbose --repository /home/ec2-user/my_project/shared/cached-copy https://bitbucket_user_id@bitbucket.org/bitbucket_user_id/my_project && hg update --verbose --repository /home/ec2-user/my_project/shared/cached-copy --clean 2ec0193d60ff; else hg clone --verbose --noupdate https://bitbucket_user_id@bitbucket.org/bitbucket_user_id/my_project /home/ec2-user/my_project/shared/cached-copy && hg update --verbose --repository /home/ec2-user/my_project/shared/cached-copy --clean 2ec0193d60ff; fi"
servers: "ec2-123-456-78-999.compute-1.amazonaws.com"
ec2-123-456-78-999.compute-1.amazonaws.com executing command
** ec2-123-456-78-999.compute-1.amazonaws.com :: out http authorization required
** ec2-123-456-78-999.compute-1.amazonaws.com :: out realm: Bitbucket.org HTTP
** ec2-123-456-78-999.compute-1.amazonaws.com :: out user: bitbucket_user_id
** ec2-123-456-78-999.compute-1.amazonaws.com :: out password:
hg password:
** ec2-123-456-78-999.compute-1.amazonaws.com :: out
** ec2-123-456-78-999.compute-1.amazonaws.com :: out abort: authorization failed
command finished in 5410ms
*** deploy:update_code rolling back
* executing "rm -rf /home/ec2-user/my_project/releases/20130110184415; true"
servers: "ec2-123-456-78-999.compute-1.amazonaws.com"
ec2-123-456-78-999.compute-1.amazonaws.com executing command
command finished in 431ms
failed: "sh -c 'if -d /home/ec2-user/my_project/shared/cached-copy ; then hg pull --verbose --repository /home/ec2-user/my_project/shared/cached-copy https://bitbucket_user_id@bitbucket.org/bitbucket_user_id/my_project && hg update --verbose --repository /home/ec2-user/my_project/shared/cached-copy --clean 2ec0193d60ff; else hg clone --verbose --noupdate https://bitbucket_user_id@bitbucket.org/bitbucket_user_id/my_project /home/ec2-user/my_project/shared/cached-copy && hg update --verbose --repository /home/ec2-user/my_project/shared/cached-copy --clean 2ec0193d60ff; fi'" on ec2-123-456-78-999.compute-1.amazonaws.com
これは私の Capistrano deploy.rb ファイルです
set :application, "my_project"
set :repository, "https://bitbucket_user_id@bitbucket.org/bitbucket_user_id/my_project"
set :keep_releases, 4
set :scm, :mercurial
set :scm_username, "bitbucket_user_id"
default_run_options:pty = true
set :scm_prefer_prompt, :true
set :scm_verbose, :true
set :deploy_to, "/home/ec2-user/#{application}"
set :deploy_via, :remote_cache
set :user, "ec2-user"
set :use_sudo, false
namespace :deploy do
desc "Gracefully restarting unicorn"
task :restart, :roles => :app do
run "sudo /etc/init.d/start_script upgrade"
end
task :start, :roles => :app do
run "sudo /etc/init.d/start_script start"
end
task :stop, :roles => :app do
run "sudo /etc/init.d/start_script stop"
end
task :link, :roles => :app do
run "mkdir -p #{shared_path}/images"
run "ln -nfs #{shared_path}/images #{release_path}/tmp/images"
end
end
コマンドラインでこれを手動で試しました
ssh ec2-user@ec2-123-456-78-999.compute-1.amazonaws.com "hg clone --verbose --noupdate https://bitbucket_user_id@bitbucket.org/bitbucket_user_id/my_project /home/ec2-user/my_project/shared/cached-copy"
そして、私は(bitbucketパスワードのプロンプトは表示されません)
abort: http authorization required
私は試した
ssh -t ec2-user@ec2-123-456-78-999.compute-1.amazonaws.com "hg clone --verbose --noupdate https://bitbucket_user_id@bitbucket.org/bitbucket_user_id/my_project /home/ec2-user/my_project/shared/cached-copy"
そしてそれはうまくいきました。
カピストラーノはsshを使用していると思います(私のdeploy.rbのこの行で疑似ttyがオンになっています)
default_run_options[:pty] = true
動作するはずですが、Capistrano では動作しないのはなぜですか?
誰かがこれを手伝ってくれますか?
どうもありがとう!