過去に他のプロジェクトでこれを数回行い、最終的には機能するようになりましたが、毎回何をすべきかを正確に思い出せないようです。
私はec2 ubuntuサーバーを持っており、カピストラーノで展開しており、ラバーを使用してすべてをセットアップしています。
私のec2サーバーで、bitbucketに追加されたsshキーを生成しました(私のアカウントでは、sshキー。最初はプロジェクトと展開キーで試しましたが、どちらもうまくいきませんでした)。私のec2サーバーでは、手動でsshして、レポを自宅に直接クローンできます。ssh エージェントにキーを追加しました。
scm を使用せずに deploy_via を :copy に設定すると、問題なくデプロイできます。これでローカル プロジェクトが取得され、デプロイされると思います。
これらを読みました: https://confluence.atlassian.com/display/BITBUCKET/Using+Deployment+Keys https://confluence.atlassian.com/display/BITBUCKET/Troubleshooting+SSH+Issues https://confluence. atlassian.com/pages/viewpage.action?pageId=270827678
これはうまくいきます:
ubuntu@production:~$ ssh -T hg@bitbucket.org
conq: logged in as myBitBucketUser.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
デプロイ中に表示されるエラー メッセージは次のとおりです。
* executing "if [ -d /mnt/myProject-production/shared/cached-copy ]; then cd /mnt/myProject-production/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard f2b5b8b6cd1c7835d020d66fdc09b42b2870561e && git clean -q -d -x -f; else git clone -q git@bitbucket.org:myRepo.git /mnt/myProject-production/shared/cached-copy && cd /mnt/myProject-production/shared/cached-copy && git checkout -q -b deploy f2b5b8b6cd1c7835d020d66fdc09b42b2870561e; fi"
servers: ["production.myserver.com"]
[production.myserver.com] executing command
** [production.myserver.com :: out] Permission denied (publickey).
** fatal: The remote end hung up unexpectedly
ここに私の deploy.rb があります:
set :rails_env, Rubber.env
on :load do
set :application, rubber_env.app_name
set :runner, rubber_env.app_user
set :deploy_to, "/mnt/#{application}-#{Rubber.env}"
set :copy_exclude, [".git/*", ".bundle/*", "log/*", ".rvmrc"]
end
# Use a simple directory tree copy here to make demo easier.
# You probably want to use your own repository for a real app
#set :scm, :none
#set :repository, "."
#set :deploy_via, :copy
ssh_options[:forward_agent] = true # also tried false
set :repository, "git@bitbucket.org:myProject.git"
set :scm, "git"
set :deploy_via, :remote_cache
set :branch, 'master'
# Easier to do system level config as root - probably should do it through
# sudo in the future. We use ssh keys for access, so no passwd needed
set :user, 'root'
set :password, nil
# Use sudo with user rails for cap deploy:[stop|start|restart]
# This way exposed services (mongrel) aren't running as a privileged user
set :use_sudo, false # also tried true