From 05e92d417be34a6bf3d24df754e8299af5088af5 Mon Sep 17 00:00:00 2001 From: Dong Ma Date: Tue, 20 Sep 2016 03:31:09 -0700 Subject: [PATCH] Update mailer plugin - update mailer plugin to use convert xml - add plugin="mailer" attribute - update doc to 4 space indent syntax Change-Id: Ib1fd30c4e1a82a0649e452b9bf03136d1e7c5ca6 --- jenkins_jobs/modules/publishers.py | 15 ++++++++------- tests/publishers/fixtures/email-complete.xml | 2 +- tests/publishers/fixtures/email-minimal.xml | 2 +- .../fixtures/project_flow_template002.xml | 2 +- .../template_override_project_level_defaults.xml | 2 +- tests/yamlparser/fixtures/templates001.xml | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 1a4ebf8eb..2f4154957 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -1792,11 +1792,11 @@ def email(registry, xml_parent, data): :arg str recipients: Space separated list of recipient email addresses - (required) + (required) :arg bool notify-every-unstable-build: Send an email for every - unstable build (default true) + unstable build (default true) :arg bool send-to-individuals: Send an email to the individual - who broke the build (default false) + who broke the build (default false) Example: @@ -1811,10 +1811,11 @@ def email(registry, xml_parent, data): # TODO: raise exception if this is applied to a maven job mailer = XML.SubElement(xml_parent, 'hudson.tasks.Mailer') - try: - XML.SubElement(mailer, 'recipients').text = data['recipients'] - except KeyError as e: - raise MissingAttributeError(e) + mailer.set('plugin', 'mailer') + mapping = [ + ('recipients', 'recipients', None) + ] + helpers.convert_mapping_to_xml(mailer, data, mapping, fail_required=True) # Note the logic reversal (included here to match the GUI if data.get('notify-every-unstable-build', True): diff --git a/tests/publishers/fixtures/email-complete.xml b/tests/publishers/fixtures/email-complete.xml index 7c7447af9..5f9d33eac 100644 --- a/tests/publishers/fixtures/email-complete.xml +++ b/tests/publishers/fixtures/email-complete.xml @@ -1,7 +1,7 @@ - + foo@example.com bar@example.com true true diff --git a/tests/publishers/fixtures/email-minimal.xml b/tests/publishers/fixtures/email-minimal.xml index aedd0c77f..7dfa3646b 100644 --- a/tests/publishers/fixtures/email-minimal.xml +++ b/tests/publishers/fixtures/email-minimal.xml @@ -1,7 +1,7 @@ - + foo@example.com false false diff --git a/tests/yamlparser/fixtures/project_flow_template002.xml b/tests/yamlparser/fixtures/project_flow_template002.xml index 74f04ae66..13b80d370 100644 --- a/tests/yamlparser/fixtures/project_flow_template002.xml +++ b/tests/yamlparser/fixtures/project_flow_template002.xml @@ -23,7 +23,7 @@ build("job2c") - + developer@nowhere.net false false diff --git a/tests/yamlparser/fixtures/template_override_project_level_defaults.xml b/tests/yamlparser/fixtures/template_override_project_level_defaults.xml index 10807152e..1fff6aa4b 100644 --- a/tests/yamlparser/fixtures/template_override_project_level_defaults.xml +++ b/tests/yamlparser/fixtures/template_override_project_level_defaults.xml @@ -57,7 +57,7 @@ - + qa@example.com false false diff --git a/tests/yamlparser/fixtures/templates001.xml b/tests/yamlparser/fixtures/templates001.xml index 086c8d499..9ebef3e49 100644 --- a/tests/yamlparser/fixtures/templates001.xml +++ b/tests/yamlparser/fixtures/templates001.xml @@ -15,7 +15,7 @@ - + projmanager@nowhere.net false false @@ -41,7 +41,7 @@ - + developer@nowhere.net false false