diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index c4409de75..cdb7dc023 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -1312,18 +1312,16 @@ def email(parser, xml_parent, data): :arg bool send-to-individuals: Send an email to the individual who broke the build (default false) - Example:: + Example: - publishers: - - email: - recipients: breakage@example.com + .. literalinclude:: /../../tests/publishers/fixtures/email001.yaml + :language: yaml """ # TODO: raise exception if this is applied to a maven job mailer = XML.SubElement(xml_parent, 'hudson.tasks.Mailer') - if 'recipients' in data: - XML.SubElement(mailer, 'recipients').text = data['recipients'] + XML.SubElement(mailer, 'recipients').text = data.get('recipients', '') # Note the logic reversal (included here to match the GUI if data.get('notify-every-unstable-build', True): diff --git a/tests/publishers/fixtures/email001.xml b/tests/publishers/fixtures/email001.xml new file mode 100644 index 000000000..e0a0628c1 --- /dev/null +++ b/tests/publishers/fixtures/email001.xml @@ -0,0 +1,10 @@ + + + + + foo@example.com bar@example.com + false + false + + + diff --git a/tests/publishers/fixtures/email001.yaml b/tests/publishers/fixtures/email001.yaml new file mode 100644 index 000000000..e2bb3a3b7 --- /dev/null +++ b/tests/publishers/fixtures/email001.yaml @@ -0,0 +1,3 @@ +publishers: + - email: + recipients: foo@example.com bar@example.com diff --git a/tests/publishers/fixtures/email002.xml b/tests/publishers/fixtures/email002.xml new file mode 100644 index 000000000..e36117f79 --- /dev/null +++ b/tests/publishers/fixtures/email002.xml @@ -0,0 +1,10 @@ + + + + + + false + true + + + diff --git a/tests/publishers/fixtures/email002.yaml b/tests/publishers/fixtures/email002.yaml new file mode 100644 index 000000000..c8a8b3ea0 --- /dev/null +++ b/tests/publishers/fixtures/email002.yaml @@ -0,0 +1,4 @@ +publishers: + - email: + send-to-individuals: true +