我过去曾为其他项目做过几次,并最终让它发挥作用,但每次我似乎都不记得到底该做什么。
我有一个 ec2 ubuntu 服务器,正在使用 capistrano 进行部署,并使用橡胶来设置 evertyhing。
在我的 ec2 服务器上,我生成了 ssh 密钥,添加到 bitbucket(在我的帐户下,ssh 密钥。起初我尝试在项目和部署密钥下,但这也不起作用)。在我的 ec2 服务器上,我可以成功手动 ssh 并直接将我的 repo 克隆到我的家中。我已将密钥添加到 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