DevOps Zone is brought to you in partnership with:

I enjoy programming in my free time and spend a considerable amount of time hacking away at open source projects as well as implementing those projects for various clients. My recent interests have included messaging (RabbitMQ specifically), Node.js, NoSQL, and alternative JVM languages such as Scala. You can also occasionally find me at several conferences speaking on some of my passions as well. Of course, got to balance all of this out with my wonderful baby girl and beautiful wife. James is a DZone MVB and is not an employee of DZone and has posted 20 posts at DZone. You can read more from them at their website. View Full User Profile

Capistrano Deployment from Jenkins

09.11.2012
| 5232 views |
  • submit to reddit

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:

!#/bin/sh
ssh-add
cap $1 deploy

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. :)

 

Published at DZone with permission of James Carr, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)