我正在尝试设置Capistrano以使用多个git用户部署我的项目。我工作的地方,没有(也不想拥有)通用的git用户,比如'git'。因此,部署配置与运行“cap deploy”的用户相关。
您可以在config.rb文件中找到:
set :application, "mywebsite"
set :repository, "ssh://#{scm_user}@myserver.com/repo.git"
set :scm, :git
set :scm_verbose, true
set :deploy_via, :remote_cache
set :git_enable_submodules, 1
development.rb
set :deploy_to, "/var/www/html"
set :user, "myuser"
set :password, "mypassword"
set :scm_passphrase, "mypassword"
和cat~ / .caprc文件:
set :scm_user, "myuser"
适用于首次部署的用户。当其他用户尝试在自己的机器上执行相同操作时,它无法正常工作。
错误与git有关。似乎Git正在绑定在第一次部署时创建git clone的用户
这些方面的基本内容:
executing locally: "git ls-remote ssh://THEOTHERUSER@myserver.com/repo.git HEAD"
* executing "if [ -d /var/www/html/shared/cached-copy ];
then cd /var/www/html/shared/cached-copy
&& git fetch origin
&& git fetch --tags origin
&& git reset --hard 88d6aa98c52babe9368cf2bed36741f0f0b93ff2
&& git submodule init
&& git submodule sync
&& export GIT_RECURSIVE=$([ ! \"`git --version`\" \\< \"git version 1.6.5\" ]
&& echo --recursive)
&& git submodule update --init $GIT_RECURSIVE
&& git clean -d -x -f; else git clone ssh://THEOTHERUSER@myserver.com/repo.git /var/www/html/shared/cached-copy && cd /var/www/html/shared/cached-copy
&& git checkout -b deploy 88d6aa98c52babe9368cf2bed36741f0f0b93ff2
&& git submodule init
&& git submodule sync
&& export GIT_RECURSIVE=$([ ! \"`git --version`\" \\< \"git version 1.6.5\" ]
&& echo --recursive)
&& git submodule update --init $GIT_RECURSIVE; fi"
当我尝试调试此问题时,我使用THEOTHERUSER ssh帐户访问了服务器计算机并输入了git fetch --tags origin
。它要求输入其他用户的密码。
有谁知道我该怎么做才能允许任何用户进行部署?
更新
需要做什么:
set :remote, "#{scm_user}"
set :branch, "master"
http://ruby-doc.org/gems/docs/c/capistrano-edge-2.5.6/Capistrano/Deploy/SCM/Git.html
答案 0 :(得分:1)
如果将存储库行替换为此怎么办?
set :repository, "ssh://myserver.com/repo.git"
答案 1 :(得分:1)
如果要将私有存储库部署为非通用用户,则必须设置ssh代理转发。这样你的ssh密钥也将在服务器上使用。
查看有关该主题的extensive GitHub documentation。