Pass the Job to the parameter function

Pass a reference to the current job about to be run to the custom
parameter function.

Remove the un-needed ZUUL_SHORT_* parameters.

Change-Id: I39538b3815ce89fae0b59c21c5cff588509cfe4e
diff --git a/NEWS.rst b/NEWS.rst
index 4aeacb9..2cb5012 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -6,11 +6,17 @@
   straightforward.  See the Launchers section of the documentation for
   details.
 
-* The custom parameter function signature now takes a QueueItem as the
-  first argument, rather than the Change.  The QueueItem has the full
-  context for why the change is being run (including the pipeline,
-  items ahead and behind, etc.).  The Change is still available via
-  the "change" attribute on the QueueItem.
+* The custom parameter function signature has changed.  It now takes a
+  QueueItem as the first argument, rather than the Change.  The
+  QueueItem has the full context for why the change is being run
+  (including the pipeline, items ahead and behind, etc.).  The Change
+  is still available via the "change" attribute on the QueueItem.  The
+  second argument is now the Job that is about to be run, ande the
+  parameter dictionary is shifted to the third position.
+
+* The ZUUS_SHORT_* parameters have been removed (the same
+  functionality may be achieved with a custom parameter function that
+  matches all jobs).
 
 * The default behavior is now to immediately dequeue changes that have
   merge conflicts, even those not at the head of the queue.  To enable
diff --git a/doc/source/zuul.rst b/doc/source/zuul.rst
index f11972c..817a57a 100644
--- a/doc/source/zuul.rst
+++ b/doc/source/zuul.rst
@@ -485,7 +485,7 @@
   included with the :ref:`includes` directive.  The function
   should have the following signature:
 
-  .. function:: parameters(item, parameters)
+  .. function:: parameters(item, job, parameters)
 
      Manipulate the parameters passed to a job before a build is
      launched.  The ``parameters`` dictionary will already contain the
@@ -494,6 +494,8 @@
 
      :param item: the current queue item
      :type item: zuul.model.QueueItem
+     :param job: the job about to be run
+     :type job: zuul.model.Job
      :param parameters: parameters to be passed to the job
      :type parameters: dict
 
diff --git a/zuul/launcher/gearman.py b/zuul/launcher/gearman.py
index 8d026b1..db285c1 100644
--- a/zuul/launcher/gearman.py
+++ b/zuul/launcher/gearman.py
@@ -13,6 +13,7 @@
 # under the License.
 
 import gear
+import inspect
 import json
 import logging
 import time
@@ -245,8 +246,6 @@
             params['ZUUL_REFNAME'] = item.change.ref
             params['ZUUL_OLDREV'] = item.change.oldrev
             params['ZUUL_NEWREV'] = item.change.newrev
-            params['ZUUL_SHORT_OLDREV'] = item.change.oldrev[:7]
-            params['ZUUL_SHORT_NEWREV'] = item.change.newrev[:7]
 
             params['ZUUL_REF'] = item.change.ref
             params['ZUUL_COMMIT'] = item.change.newrev
@@ -271,11 +270,13 @@
         # optional (ref updated only):
         # ZUUL_OLDREV
         # ZUUL_NEWREV
-        # ZUUL_SHORT_NEWREV
-        # ZUUL_SHORT_OLDREV
 
         if callable(job.parameter_function):
-            job.parameter_function(item, params)
+            pargs = inspect.getargspec(job.parameter_function)
+            if len(pargs.args) == 2:
+                job.parameter_function(item, params)
+            else:
+                job.parameter_function(item, job, params)
             self.log.debug("Custom parameter function used for job %s, "
                            "change: %s, params: %s" % (job, item.change,
                                                        params))