     msg.send "Error: jenkins plugin not installed."
     return
 
-  environment = querystring.escape msg.match[1]
-  branch = querystring.escape msg.match[2]
+  environment = querystring.escape msg.match[2]
+  branch = querystring.escape msg.match[3]
   user = msg.message.user
 
   if environment not of CONFIG


  job = CONFIG[environment].job
  role = CONFIG[environment].role
  params = "BRANCH=#{branch}"

  if not userHasRole(user, role)
     msg.send "Access denied."

# Configuration:
#   HUBOT_DEPLOY_CONFIG
#
#   CONFIG should be in JSON i.e. '{ "foo": {"job": "deploy-foo", "role": "deploy", "param": "BRANCH" } }'
#
#   The "job" field represents the name of the Jenkins job you want to invoke.
#
#   The "role" field uses the [auth.coffee][1] module for restricting access via user
#   configurable roles. You can set "role" to "*" if you don't care about restricting access.
#
#   [1]: https://github.com/github/hubot/blob/master/src/scripts/auth.coffee
#
#   The "param" field represents the name of the string parameter passed to the Jenkins
#   job.
#
# Commands:
#   hubot deploy <environment> <branch> - deploys the specified branch to the specified environment
