From 563701973830f849e2307fa10b707bf3629c69de Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Mon, 14 Jan 2013 15:47:28 -0800 Subject: [PATCH] Make report message introduction configurable. By setting parameters on a pipeline, you can change the default "Build successful/failed" introductory messages left on Gerrit. Change-Id: Ie05c8c87a47994faced4ee67fda4ab4e64ea0d20 Reviewed-on: https://review.openstack.org/19677 Reviewed-by: Clark Boylan Reviewed-by: Jeremy Stanley Approved: James E. Blair Tested-by: Jenkins --- doc/source/zuul.rst | 10 ++++++++++ tests/fixtures/layout.yaml | 1 + tests/fixtures/layouts/good_layout.yaml | 2 ++ zuul/layoutvalidator.py | 2 ++ zuul/model.py | 2 ++ zuul/scheduler.py | 8 ++++++-- 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/doc/source/zuul.rst b/doc/source/zuul.rst index 55e020138e..0c4d076a76 100644 --- a/doc/source/zuul.rst +++ b/doc/source/zuul.rst @@ -170,6 +170,16 @@ explanation of each of the parameters:: This is an optional field that may be used to provide a textual description of the pipeline. +**success-message** + An optional field that supplies the introductory text in message + reported back to Gerrit when all the voting builds are successful. + Defaults to "Build successful." + +**failure-message** + An optional field that supplies the introductory text in message + reported back to Gerrit when at least one voting build fails. + Defaults to "Build failed." + **manager** There are currently two schemes for managing pipelines: diff --git a/tests/fixtures/layout.yaml b/tests/fixtures/layout.yaml index cfe68fc3b5..586e2a5841 100644 --- a/tests/fixtures/layout.yaml +++ b/tests/fixtures/layout.yaml @@ -16,6 +16,7 @@ pipelines: - name: gate manager: DependentPipelineManager + failure-message: Build failed. For information on how to proceed, see http://wiki.example.org/Test_Failures trigger: - event: comment-added approval: diff --git a/tests/fixtures/layouts/good_layout.yaml b/tests/fixtures/layouts/good_layout.yaml index ca024ec129..112d2a601d 100644 --- a/tests/fixtures/layouts/good_layout.yaml +++ b/tests/fixtures/layouts/good_layout.yaml @@ -19,6 +19,8 @@ pipelines: - name: gate manager: DependentPipelineManager + success-message: Your change is awesome. + failure-message: Build failed. For information on how to proceed, see http://wiki.example.org/Test_Failures trigger: - event: comment-added approval: diff --git a/zuul/layoutvalidator.py b/zuul/layoutvalidator.py index eac394e1de..8d2177343d 100644 --- a/zuul/layoutvalidator.py +++ b/zuul/layoutvalidator.py @@ -45,6 +45,8 @@ class LayoutSchema(object): pipeline = {v.required('name'): str, v.required('manager'): manager, 'description': str, + 'success-message': str, + 'failure-message': str, 'trigger': toList(trigger), 'success': variable_dict, 'failure': variable_dict, diff --git a/zuul/model.py b/zuul/model.py index a7c7f0d785..acefef6d88 100644 --- a/zuul/model.py +++ b/zuul/model.py @@ -28,6 +28,8 @@ class Pipeline(object): def __init__(self, name): self.name = name self.description = None + self.failure_message = None + self.success_message = None self.job_trees = {} # project -> JobTree self.manager = None self.queues = [] diff --git a/zuul/scheduler.py b/zuul/scheduler.py index 86e78a8982..450febda02 100644 --- a/zuul/scheduler.py +++ b/zuul/scheduler.py @@ -96,6 +96,10 @@ class Scheduler(threading.Thread): for conf_pipeline in data.get('pipelines', []): pipeline = Pipeline(conf_pipeline['name']) pipeline.description = conf_pipeline.get('description') + pipeline.failure_message = conf_pipeline.get('failure-message', + "Build failed.") + pipeline.success_message = conf_pipeline.get('success-message', + "Build succeeded.") manager = globals()[conf_pipeline['manager']](self, pipeline) pipeline.setManager(manager) @@ -759,9 +763,9 @@ class BasePipelineManager(object): def formatReport(self, changeish): ret = '' if self.pipeline.didAllJobsSucceed(changeish): - ret += 'Build successful\n\n' + ret += self.pipeline.success_message + '\n\n' else: - ret += 'Build failed\n\n' + ret += self.pipeline.failure_message + '\n\n' if changeish.dequeued_needing_change: ret += "This change depends on a change that failed to merge."