     catch error
       @send error
 
-  _handleLastBuildStatus: (err, res, body, server) =>
+  _handleLastBuildStatus: (err, res, body, server, folder) =>
     if err
       @send err
       return

  # Utility Methods
  # ---------------

  _addJobsToJobsList: (jobs, server, outputStatus = false) =>
    response = ""
    filter = new RegExp(@msg.match[2], 'i')

    for job in jobs
      # Add the job to the @_jobList
      server.addJob(job)
      index = @_jobList.indexOf(job.name)
      if index == -1
        @_jobList.push job.name
        index = @_jobList.indexOf(job.name)

      state = if job.color == "red" then "FAIL" else "PASS"
      if filter.test job.name
        response += "[#{index + 1}] #{state} #{job.name} on #{server.url}\n"

    @send response if outputStatus

  _configureRequest: (request, server = null) =>
    defaultAuth = process.env.HUBOT_JENKINS_AUTH
    return if not server and not defaultAuth
    selectedAuth = if server then server.auth else defaultAuth
    #auth = new Buffer(selectedAuth).toString('base64')
    #request.headers Authorization: "Basic #{auth}"
    request.header('Content-Length', 0)
    request


    job = @_getJob()
    server = @_serverManager.getServerByJobName(job)
    path = "job/#{job}/#{lastBuild.number}/api/json"
    @_requestFactorySingle server, null, path, @_handleLastBuildStatus

  _requestFactorySingle: (server, folder, endpoint, callback, method = "get") =>
    user = server.auth.split(":")
    if server.url.indexOf('https') == 0 then http = 'https://' else http = 'http://'
    url = server.url.replace /^https?:\/\//, ''
    path = "#{http}#{user[0]}:#{user[1]}@#{url}/#{endpoint}"
    console.log(path)
    request = @msg.http(path)
    @_configureRequest request, server
    request[method]() ((err, res, body) -> callback(err, res, body, server, folder))

  _requestFactory: (endpoint, callback, method = "get") =>
    for server in @_serverManager.listServers()
      @_requestFactorySingle server, server.getFolder(), endpoint, callback, method

  _setJob: (job) =>
    @msg.match[1] = job
