..

Jenkins + Capistrano + ssh-agent plugin

Ever gotten this nasty message when attempting to use the ssh-agent plugin with capistrano?:

** [deploy:update_code] exception while rolling back: 
Capistrano::ConnectionError, connection failed for: staging43 
(Net::SSH::Authentication::AgentError: unknown response from agent: 30, "\x00\x00\x00\x01\x1E")

This means that:

What’s the workaround?

20131127a.png

Drop the following into the execute shell block which runs the deployment task:

eval `ssh-agent`
echo $SSH_AGENT_PID > ssh-agent.pid
ssh-add
bundle exec cap deploy

And then, add another execute shell block:

kill -9 `cat ssh-agent.pid`

20131127b.png

What does the workaround do?