Content-Type can now be set for email-ext publisher
The email-ext publisher was always sending email using the default content type which is server wide. This tiny patch let us overwrite the content-type on a job basis. The YAML possible values are 'html' or 'text' to force the content-type to one of the two modes. Change-Id: Id66bc3369332c389dfb6318113392694a4f98aad
This commit is contained in:
parent
e53ac245ad
commit
7ca5b01e8c
@ -1382,6 +1382,9 @@ def email_ext(parser, xml_parent, data):
|
|||||||
:arg str recipients: Comma separated list of emails
|
:arg str recipients: Comma separated list of emails
|
||||||
:arg str reply-to: Comma separated list of emails that should be in
|
:arg str reply-to: Comma separated list of emails that should be in
|
||||||
the Reply-To header for this project (default is $DEFAULT_RECIPIENTS)
|
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
|
:arg str subject: Subject for the email, can include variables like
|
||||||
${BUILD_NUMBER} or even groovy or javascript code
|
${BUILD_NUMBER} or even groovy or javascript code
|
||||||
:arg str body: Content for the body of the email, can include variables
|
: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')
|
base_email_ext(parser, ctrigger, data, 'StillUnstableTrigger')
|
||||||
if data.get('pre-build', False):
|
if data.get('pre-build', False):
|
||||||
base_email_ext(parser, ctrigger, data, 'PreBuildTrigger')
|
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(
|
XML.SubElement(emailext, 'defaultSubject').text = data.get(
|
||||||
'subject', '$DEFAULT_SUBJECT')
|
'subject', '$DEFAULT_SUBJECT')
|
||||||
XML.SubElement(emailext, 'defaultContent').text = data.get(
|
XML.SubElement(emailext, 'defaultContent').text = data.get(
|
||||||
|
@ -137,7 +137,7 @@
|
|||||||
</email>
|
</email>
|
||||||
</hudson.plugins.emailext.plugins.trigger.PreBuildTrigger>
|
</hudson.plugins.emailext.plugins.trigger.PreBuildTrigger>
|
||||||
</configuredTriggers>
|
</configuredTriggers>
|
||||||
<contentType>default</contentType>
|
<contentType>text/html</contentType>
|
||||||
<defaultSubject>Subject for Build ${BUILD_NUMBER}</defaultSubject>
|
<defaultSubject>Subject for Build ${BUILD_NUMBER}</defaultSubject>
|
||||||
<defaultContent>The build has finished</defaultContent>
|
<defaultContent>The build has finished</defaultContent>
|
||||||
<attachmentsPattern>*/foo*.log</attachmentsPattern>
|
<attachmentsPattern>*/foo*.log</attachmentsPattern>
|
||||||
|
@ -2,6 +2,7 @@ publishers:
|
|||||||
- email-ext:
|
- email-ext:
|
||||||
recipients: foo@example.com, bar@example.com
|
recipients: foo@example.com, bar@example.com
|
||||||
reply-to: foo@example.com
|
reply-to: foo@example.com
|
||||||
|
content-type: html
|
||||||
subject: Subject for Build ${BUILD_NUMBER}
|
subject: Subject for Build ${BUILD_NUMBER}
|
||||||
body: The build has finished
|
body: The build has finished
|
||||||
attach-build-log: false
|
attach-build-log: false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user