The email publisher needs a list of recipients
The email publisher will throw a NullPointerException of the recipients xml element does not exist, so if there are no recipients then set the value to an empty string in order to get an empty xml element in the config. Also add tests for the email publisher. story: 2000015 Change-Id: I7b4fdd4904eea1918ae80f5db6c7b0aaedbaef99
This commit is contained in:
parent
74c8ac4561
commit
2f9f589fe5
|
@ -1298,18 +1298,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):
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.tasks.Mailer>
|
||||
<recipients>foo@example.com bar@example.com</recipients>
|
||||
<dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
|
||||
<sendToIndividuals>false</sendToIndividuals>
|
||||
</hudson.tasks.Mailer>
|
||||
</publishers>
|
||||
</project>
|
|
@ -0,0 +1,3 @@
|
|||
publishers:
|
||||
- email:
|
||||
recipients: foo@example.com bar@example.com
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.tasks.Mailer>
|
||||
<recipients/>
|
||||
<dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
|
||||
<sendToIndividuals>true</sendToIndividuals>
|
||||
</hudson.tasks.Mailer>
|
||||
</publishers>
|
||||
</project>
|
|
@ -0,0 +1,4 @@
|
|||
publishers:
|
||||
- email:
|
||||
send-to-individuals: true
|
||||
|
Loading…
Reference in New Issue