Platinum Partner
java,devops,tool,infrastructure,build automation

Capistrano Deployment from Jenkins

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 {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}