Over a million developers have joined DZone.

Capistrano Deployment from Jenkins

· DevOps Zone

The DevOps zone is brought to you in partnership with Sonatype Nexus. The Nexus suite helps scale your DevOps delivery with continuous component intelligence integrated into development tools, including Eclipse, IntelliJ, Jenkins, Bamboo, SonarQube and more. Schedule a demo today

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

 

The DevOps zone is brought to you in partnership with Sonatype Nexus. Use the Nexus Suite to automate your software supply chain and ensure you're using the highest quality open source components at every step of the development lifecycle. Get Nexus today

Topics:

Published at DZone with permission of James Carr, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

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

{{ parent.tldr }}

{{ parent.urlSource.name }}