Recently I had a challenge of getting capistrano deployments working from jenkins installed on a RHEL box. The problem seemed to be down to the fact that ssh-agent isn’t running for the daemon process that jenkins runs as for whatever reason and it is needed to do ssh agent forwarding (which is what I do so I can use the ssh key on the jenkins server to check code out from github on remote servers).
After banging my head against the head for a couple hours, I came up with a simple solution: execute a shell script through ssh-agent. I simply created a deploy.sh script in the root of my project with the following contents:
Then execute it through ssh agent.
exec /usr/bin/ssh-agent "${WORSKPACE}/deploy.sh" "production"
Works perfectly. Hopefully this helps someone else, took me a lot of grief to figure this out.
Oh yeah, in case you didn’t know, I’m back in PHP development again for awhile so there should be some interesting posts ahead.
No tags

David Spreekmeester · December 10, 2012 at 12:43 pm
James: thanks a BUNCH! Really. I was risking a concussion from the head-versus-screen-banging.
I would expect that Jenkins + Capistrano isn’t a really exotic combination, but somehow it took me a long time to find this post, or anything related that was helpful. I had tried configuring .ssh/config in a few different places, but that’s obviously no good.
Only thing to add is that there’s a typo in ${WORKSPACE}, for the rest this was a flawless victory!
Admin comment by James Carr · March 18, 2013 at 5:53 pm
I’m glad this helped! I spent an entire week on this issue and it was a nightmare.