Merge "Add test and update documentation for mailer plugin"

This commit is contained in:
Jenkins 2016-05-16 14:16:03 +00:00 committed by Gerrit Code Review
commit 21bece0585
6 changed files with 21 additions and 10 deletions

View File

@ -1724,9 +1724,12 @@ def pipeline(parser, xml_parent, data):
def email(parser, xml_parent, data): def email(parser, xml_parent, data):
"""yaml: email """yaml: email
Email notifications on build failure. Email notifications on build failure.
Requires the Jenkins :jenkins-wiki:`Mailer Plugin
<Mailer>`.
:arg str recipients: Space separated list of recipient email addresses :arg str recipients: Space separated list of recipient email addresses
(optional) (required)
:arg bool notify-every-unstable-build: Send an email for every :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 :arg bool send-to-individuals: Send an email to the individual
@ -1734,14 +1737,21 @@ def email(parser, xml_parent, data):
Example: Example:
.. literalinclude:: /../../tests/publishers/fixtures/email001.yaml .. literalinclude::
/../../tests/publishers/fixtures/email-minimal.yaml
:language: yaml
.. literalinclude:: /../../tests/publishers/fixtures/email-complete.yaml
:language: yaml :language: yaml
""" """
# TODO: raise exception if this is applied to a maven job # TODO: raise exception if this is applied to a maven job
mailer = XML.SubElement(xml_parent, mailer = XML.SubElement(xml_parent,
'hudson.tasks.Mailer') 'hudson.tasks.Mailer')
XML.SubElement(mailer, 'recipients').text = data.get('recipients', '') try:
XML.SubElement(mailer, 'recipients').text = data['recipients']
except KeyError as e:
raise MissingAttributeError(e)
# Note the logic reversal (included here to match the GUI # Note the logic reversal (included here to match the GUI
if data.get('notify-every-unstable-build', True): if data.get('notify-every-unstable-build', True):

View File

@ -2,8 +2,8 @@
<project> <project>
<publishers> <publishers>
<hudson.tasks.Mailer> <hudson.tasks.Mailer>
<recipients/> <recipients>foo@example.com bar@example.com</recipients>
<dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild> <dontNotifyEveryUnstableBuild>true</dontNotifyEveryUnstableBuild>
<sendToIndividuals>true</sendToIndividuals> <sendToIndividuals>true</sendToIndividuals>
</hudson.tasks.Mailer> </hudson.tasks.Mailer>
</publishers> </publishers>

View File

@ -1,3 +1,5 @@
publishers: publishers:
- email: - email:
recipients: foo@example.com bar@example.com recipients: foo@example.com bar@example.com
notify-every-unstable-build: false
send-to-individuals: true

View File

@ -2,7 +2,7 @@
<project> <project>
<publishers> <publishers>
<hudson.tasks.Mailer> <hudson.tasks.Mailer>
<recipients>foo@example.com bar@example.com</recipients> <recipients>foo@example.com</recipients>
<dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild> <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
<sendToIndividuals>false</sendToIndividuals> <sendToIndividuals>false</sendToIndividuals>
</hudson.tasks.Mailer> </hudson.tasks.Mailer>

View File

@ -0,0 +1,3 @@
publishers:
- email:
recipients: foo@example.com

View File

@ -1,4 +0,0 @@
publishers:
- email:
send-to-individuals: true