Capistrano Lighthouse integration

May 14th, 2010

In my previous post I explained how I added some git hooks to ensure that we have lighthouse ticket info added to our git commit and merge messages. This means that when we push to github, the lighthouse service hook updates the tickets in lighthouse and anyone watching the ticket gets updated. This is only half the story though, we also update the tickets both when code is deployed to the staging server or the production system. Doing this manually is a pain in the behind, so I took the time to automate it...

All I've done is created a script that can be executed from a capistrano deploy script. Capistrano already knows the SHAs of the previous and current revision, my script just takes these as a commit range, looks for lighthouse ticket references in commit and merge messages, and then uses the lighthouse api to update these tickets. When deploying to the staging server, it changes the state to 'uat' and re-assigns the ticket to the creator. When deploying to production, it just changes the stage to 'resolved'. It also both prints out a summary and emails it, with links to the tickets, to a configured email address.

Our capistrano deploy script includes a task that calls the lighthouse integration script, providing the environment and commit range as arguments. This is the very last task that gets executed as part of our deploy.

  task :lighthouse do
    run "cd #{release_path}; ./script/deploy_lighthouse #{rails_env} #{previous_revision}..#{current_revision}", :once => true

Combined with the git hooks mentioned in the previous post, this pretty much automates all updates to our ticketing system. No more manual updating, more time to code, or go to the pub, which I'm going to do in 5 minutes, it being Friday 'n' all.

Here's the code anyway, I hope someone else finds it useful - it's good to share :-)

Sorry, comments are closed for this article.