fix message report when no action is given

031e23f allowed the Gerrit trigger to report a message even when no
action has been given (for the context of postmerge builds where the
change cant be altered).  I have noticed the Gerrit lib would stack
trace because it is missing an action (actually None).  This patch skip
the action expansion in Gerrit command line whenever there is no action.

Related stacktrace:

  INFO zuul.IndependentPipelineManager: Reporting
   change <Change 0x7fb72099d190 62446,3>, action: None
  DEBUG zuul.Gerrit: Report change <Change 0x7fb72099d190 62446,3>,
   action None, message: Build succeeded.
  ERROR zuul.IndependentPipelineManager: Exception while reporting:
  Traceback (most recent call last):
  File "zuul-5b84b5c-py2.7.egg/zuul/scheduler.py",
    line 883, in reportChange
      ret = self.sched.trigger.report(change, report, action)
  File "zuul-5b84b5c-py2.7.egg/zuul/trigger/gerrit.py",
    line 142, in report message, action)
  File "zuul-5b84b5c-py2.7.egg/zuul/lib/gerrit.py",
    line 119, in review
      for k, v in action.items():
  AttributeError: 'NoneType' object has no attribute 'items'

Change-Id: I51b66025eb6e1d074d79cf77ac4085ba3ffde77e
Reviewed-on: https://review.openstack.org/28395
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
This commit is contained in:
Antoine Musso 2013-05-07 10:15:00 +02:00 committed by Jenkins
parent 88dd5109c8
commit 9ba2068664
1 changed files with 6 additions and 5 deletions

View File

@ -116,11 +116,12 @@ class Gerrit(object):
cmd = 'gerrit review --project %s' % project
if message:
cmd += ' --message "%s"' % message
for k, v in action.items():
if v is True:
cmd += ' --%s' % k
else:
cmd += ' --%s %s' % (k, v)
if action:
for k, v in action.items():
if v is True:
cmd += ' --%s' % k
else:
cmd += ' --%s %s' % (k, v)
cmd += ' %s' % change
out, err = self._ssh(cmd)
return err