         @failing.splice index, 1 if index isnt -1
 
 module.exports = (robot) ->
-  notifier = new JenkinsNotifier robot
+  robot.jenkins_notifier = new JenkinsNotifier robot
 
   robot.router.post "/hubot/jenkins-notify", (req, res) ->
-    notifier.process req, res
+    robot.jenkins_notifier.process req, res
 

    @robot = robot
    @failing = []

  error: (e) ->
    console.log "jenkins-notify error: #{error}. Data: #{req.body}"
    console.log error.stack

  shouldNotify: (notstrat, data) ->
    if data.build.status == 'FAILURE'

    try
      # Newer versions of express/hubot already process posts that have Content-Type application/json
      for key of req.body
        # breaks in 0.11
        if key == '__proto__'
          continue
        data = JSON.parse key
        break
    catch err
      @error err, req.body
      try
        data = req.body
      catch error
        @error err, req.body
        return

    if typeof data.build != 'object'
      @error new Error("Unable to process data"), req.body
      return

    if data.build.phase == 'FINISHED'
      if data.build.status == 'FAILURE'
