2015-05-04 179 views
4

我想部署在Windows機器與git bash。 以下是我的staging.rb文件。在Windows上部署Capistrano失敗與git

set :stage, :staging 
set :chruby_ruby, '2.2' 
set :rails_env, :staging 

#set :branch, '15_inaccurate-line-on-map' 
set :branch, 'staging' 

set :ssh_options, { 
    forward_agent: true 
} 

set :rvm_roles, [:some] 
set :rvm_map_bins, [] 

server 'XX.XX.XX.XX', user: 'deploy', roles: %w(web app db) 

存儲庫在bitbucket上。我在bitbucket和服務器上添加了我的密鑰。 因此,當我嘗試bash時,這些命令是成功的。

ssh [email protected] 

ssh -A [email protected] 'git ls-remote --heads [email protected]:<user>/<repo>.git' 

git pull origin staging 

的問題是我看到錯誤的混帳:檢查時,我想蓋分期部署

INFO [548342cf] Running /usr/bin/env mkdir -p /tmp/butlermaps/ as [email protected] 
INFO [548342cf] Finished in 3.145 seconds with exit status 0 (successful). 
INFO Uploading /tmp/butlermaps/git-ssh.sh 100.0% 
INFO [2f19d649] Running /usr/bin/env chmod +x /tmp/butlermaps/git-ssh.sh as depl 
[email protected] 
INFO [2f19d649] Finished in 0.487 seconds with exit status 0 (successful). 
** Execute git:check 
INFO [61e3a414] Running /usr/bin/env git ls-remote --heads [email protected]:<user>/<repo>.git 
as [email protected] 
cap aborted! 
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: 
git exit status: 128 
git stdout: Nothing written 
git stderr: Error reading response length from authentication socket. 
conq: repository access denied. 
fatal: The remote end hung up unexpectedly 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel. 
rb:16:in `rescue in block (2 levels) in execute' 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel. 
rb:12:in `block (2 levels) in execute' 
SSHKit::Command::Failed: git exit status: 128 
git stdout: Nothing written 
git stderr: Error reading response length from authentication socket. 
conq: repository access denied. 
fatal: The remote end hung up unexpectedly 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/command.rb:95:in 
`exit_status=' 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.r 
b:179:in `block in _execute' 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.r 
b:133:in `tap' 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.r 
b:133:in `_execute' 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.r 
b:66:in `execute' 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/capistrano-3.4.0/lib/capistrano/git.rb:11 
:in `git' 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/capistrano-3.4.0/lib/capistrano/git.rb:21 
:in `check' 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/capistrano-3.4.0/lib/capistrano/tasks/git 
.rake:28:in `block (4 levels) in <top (required)>' 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/abstract 
.rb:85:in `with' 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/capistrano-3.4.0/lib/capistrano/tasks/git 
.rake:27:in `block (3 levels) in <top (required)>' 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.r 
b:54:in `instance_exec' 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.r 
b:54:in `run' 
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel. 
rb:13:in `block (2 levels) in execute' 
Tasks: TOP => git:check 
The deploy has failed with an error: Exception while executing as [email protected]: 
git exit status: 128 
git stdout: Nothing written 
git stderr: Error reading response length from authentication socket. 
conq: repository access denied. 
fatal: The remote end hung up unexpectedly 
** Invoke deploy:failed (first_time) 
** Execute deploy:failed 

任何人有一個想法,爲什麼它失敗的混帳:檢查?

任何形式的幫助表示讚賞。

回答

2

所以你的問題實際上是部署服務器的git權限。部署服務器無法進入存儲庫,因爲它的公鑰是作爲個人密鑰添加到之前有權訪問存儲庫的帳戶的,但最近撤消了哪些訪問權限,因此部署服務器訪問也被撤銷。

雖然cap staging deploy仍然爲另一個開發者(我)工作,這是一個神祕的。也許是因爲我有了oh-my-zsh,它正在爲我的SSH密鑰代理服務器。

其實,我發現你用Google搜索錯誤信息的問題,我試圖爲其他開發者設置部署,這很有趣。

因此,一般的解決方案是:將您的部署服務器帳戶添加到存儲庫的「部署密鑰」中,人員!不要私人鑰匙。

+0

它像魅力一樣工作!非常感謝伊戈爾。 – sean