Last Updated: February 25, 2016
·
637
· weyus

Notify Airbrake of a deployment of a Node.js project using capistrano

In the Node.js project root directory, create a deploy.js file, like so:

var airbrake = require('airbrake').createClient("AIRBRAKE_API_KEY");

var deployment = {rev: process.argv[2],
                  repo: process.argv[3],
                  env: process.argv[4],
                  user: process.argv[5]};

airbrake.trackDeployment(deployment, function(err, params) {
  if (err) {throw err}
  console.log('Tracked deployment of %s to %s', params.rev, params.env);
})

In config/deploy.rb, add

require 'airbrake/capistrano'

and

namespace :airbrake do
  desc "Notify Airbrake of a new deploy."
  task :deploy do
    system "node deploy.js #{current_revision} #{repository} #{stage} #{user}"
  end
end