report message even if no action is specified
Whenever a pipeline does not provide any action, the job message would
not be reported which is a bit annoying. This patch makes it so we skip
reporting when there is no action and no message.
My use case is:
A `postmerge` pipeline that simply react to the `change-merged` events,
since the change is closed, there is no point in voting on it. Jobs
then uses the `success-message` and `failure-message` to finely tune
what is reported back to the user.
Configuration exemple
pipelines:
- name: postmerge
manager: IndependentPipelineManager
trigger:
- event: change-merged
projects:
- name: operations/config
postmerge:
- operations-config-deploy
jobs:
- name: operations-config-deploy
branch: ^production$
success-message: 'Your configuration has been deployed by Jenkins.'
failure-message: 'Configuration NOT APPLIED. You broke wikipedia.'
Before this patch, the debug would be:
------------8<---------------8<---------------8<-----------------------
INFO zuul.IndependentPipelineManager: Reporting
change <Change 0x7f67a0d61f50 61980,1>, action: None
DEBUG zuul.Gerrit: Report change <Change
0x7f67a0d61f50 61980,1>, action None, message: Build succeeded.
- https://jenkins-url-goes-there.example.com/
: Your configuration has been deployed by Jenkins.
DEBUG zuul.Gerrit: No action specified; not reporting
DEBUG zuul.IndependentPipelineManager: Removing reported
------------8<---------------8<---------------8<-----------------------
Change-Id: I9ab4d47a8cfc1ae66870e8ac55e8f78dfc29da3d
Reviewed-on: https://review.openstack.org/28045
Reviewed-by: Jesse Keating <jesse.keating@rackspace.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
diff --git a/zuul/trigger/gerrit.py b/zuul/trigger/gerrit.py
index 3a2a028..18251e4 100644
--- a/zuul/trigger/gerrit.py
+++ b/zuul/trigger/gerrit.py
@@ -131,8 +131,8 @@
if not change.number:
self.log.debug("Change has no number; not reporting")
return
- if not action:
- self.log.debug("No action specified; not reporting")
+ if not action and not message:
+ self.log.debug("No action or message specified; not reporting")
return
changeid = '%s,%s' % (change.number, change.patchset)
ref = 'refs/heads/' + change.branch