Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Accessing Rake tasks outside a Rails app

Mange edited this page · 1 revision

Any rails app that uses Airbrake will have certain Rake tasks loaded and usable. If you want to access these rake tasks in a non-Rails app (to get deploy notifications using the standard capistrano recipes, for example) you'll have to add them manually.

Here's a code sample with extra comments:

# Rakefile

# If there's a problem loading the tasks, we don't want Rake to crash. Most of these are non-critical after all.
  # Load the default airbrake tasks
  require 'airbrake/tasks'
  # Load the API key from a file in the repo
  api_key = YAML.load_file(File.expand_path '../config/airbrake.yml', __FILE__)['api_key']
  # Load the API key from the environment
  # api_key = ENV['AIRBRAKE_API_KEY'] or raise "No API key in ENV"

  # Airbrake tasks read the API key from this configuration when run
  Airbrake.configuration.api_key = api_key
  $stderr.puts "Could not load Airbrake configuration!"

Then either add a config file to load from, or set the environment (depending on what you need).

Something went wrong with that request. Please try again.