Merge "Content-Type can now be set for email-ext publisher"

This commit is contained in:
Jenkins 2014-03-06 09:26:50 +00:00 committed by Gerrit Code Review
commit bed596e8c6
3 changed files with 17 additions and 2 deletions

View File

@ -1382,6 +1382,9 @@ def email_ext(parser, xml_parent, data):
:arg str recipients: Comma separated list of emails
:arg str reply-to: Comma separated list of emails that should be in
the Reply-To header for this project (default is $DEFAULT_RECIPIENTS)
:arg str content-type: The content type of the emails sent. If not set, the
Jenkins plugin uses the value set on the main configuration page.
Possible values: 'html', 'text' or 'default' (default 'default')
:arg str subject: Subject for the email, can include variables like
${BUILD_NUMBER} or even groovy or javascript code
:arg str body: Content for the body of the email, can include variables
@ -1447,7 +1450,18 @@ def email_ext(parser, xml_parent, data):
base_email_ext(parser, ctrigger, data, 'StillUnstableTrigger')
if data.get('pre-build', False):
base_email_ext(parser, ctrigger, data, 'PreBuildTrigger')
XML.SubElement(emailext, 'contentType').text = 'default'
content_type_mime = {
'text': 'text/plain',
'html': 'text/html',
'default': 'default',
}
ctype = data.get('content-type', 'default')
if ctype not in content_type_mime:
raise JenkinsJobsException('email-ext content type must be one of: %s'
% ', '.join(content_type_mime.keys()))
XML.SubElement(emailext, 'contentType').text = content_type_mime[ctype]
XML.SubElement(emailext, 'defaultSubject').text = data.get(
'subject', '$DEFAULT_SUBJECT')
XML.SubElement(emailext, 'defaultContent').text = data.get(

View File

@ -137,7 +137,7 @@
</email>
</hudson.plugins.emailext.plugins.trigger.PreBuildTrigger>
</configuredTriggers>
<contentType>default</contentType>
<contentType>text/html</contentType>
<defaultSubject>Subject for Build ${BUILD_NUMBER}</defaultSubject>
<defaultContent>The build has finished</defaultContent>
<attachmentsPattern>*/foo*.log</attachmentsPattern>

View File

@ -2,6 +2,7 @@ publishers:
- email-ext:
recipients: foo@example.com, bar@example.com
reply-to: foo@example.com
content-type: html
subject: Subject for Build ${BUILD_NUMBER}
body: The build has finished
attach-build-log: false