Merge "Pass the Job to the parameter function"

This commit is contained in:
Jenkins 2013-07-31 21:17:16 +00:00 committed by Gerrit Code Review
commit 4604435830
3 changed files with 20 additions and 11 deletions

View File

@ -6,11 +6,17 @@ Since 1.3.0:
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

View File

@ -485,7 +485,7 @@ each job as it builds a list from the project specification.
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 @@ each job as it builds a list from the project specification.
: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

View File

@ -13,6 +13,7 @@
# under the License.
import gear
import inspect
import json
import logging
import time
@ -245,8 +246,6 @@ class Gearman(object):
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 @@ class Gearman(object):
# 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))