Capistrano Deployment from Jenkins
Join the DZone community and get the full member experience.
Join For FreeRecently 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, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Apache Kafka vs. Message Queue: Trade-Offs, Integration, Migration
-
File Upload Security and Malware Protection
-
Observability Architecture: Financial Payments Introduction
-
Logging Best Practices Revisited [Video]
Comments