diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py
index ca446a158..1b37a5804 100755
--- a/jenkins_jobs/modules/publishers.py
+++ b/jenkins_jobs/modules/publishers.py
@@ -2454,37 +2454,124 @@ def base_email_ext(registry, xml_parent, data, ttype):
trigger = XML.SubElement(
xml_parent, "hudson.plugins.emailext.plugins.trigger." + ttype
)
+
+ info = registry.get_plugin_info("email-ext")
+ plugin_version = pkg_resources.parse_version(info.get("version", str(sys.maxsize)))
+
email = XML.SubElement(trigger, "email")
- XML.SubElement(email, "recipientList").text = ""
+
+ if plugin_version < pkg_resources.parse_version("2.39"):
+ XML.SubElement(email, "recipientList").text = ""
XML.SubElement(email, "subject").text = "$PROJECT_DEFAULT_SUBJECT"
XML.SubElement(email, "body").text = "$PROJECT_DEFAULT_CONTENT"
+ if plugin_version >= pkg_resources.parse_version("2.39"):
+ XML.SubElement(email, "replyTo").text = "$PROJECT_DEFAULT_REPLYTO"
+ XML.SubElement(email, "contentType").text = "project"
if "send-to" in data:
- XML.SubElement(email, "sendToDevelopers").text = str(
- "developers" in data["send-to"]
- ).lower()
- XML.SubElement(email, "sendToRequester").text = str(
- "requester" in data["send-to"]
- ).lower()
- XML.SubElement(email, "includeCulprits").text = str(
- "culprits" in data["send-to"]
- ).lower()
- XML.SubElement(email, "sendToRecipientList").text = str(
- "recipients" in data["send-to"]
- ).lower()
- if "upstream-committers" in data["send-to"]:
+ recipient_providers = None
+ if plugin_version < pkg_resources.parse_version("2.39"):
+ XML.SubElement(email, "sendToDevelopers").text = str(
+ "developers" in data["send-to"]
+ ).lower()
+ XML.SubElement(email, "sendToRequester").text = str(
+ "requester" in data["send-to"]
+ ).lower()
+ XML.SubElement(email, "includeCulprits").text = str(
+ "culprits" in data["send-to"]
+ ).lower()
+ XML.SubElement(email, "sendToRecipientList").text = str(
+ "recipients" in data["send-to"]
+ ).lower()
+ else:
+ for recipient in data["send-to"]:
+ if "developers" == recipient:
+ if recipient_providers is None:
+ recipient_providers = XML.SubElement(
+ email, "recipientProviders"
+ )
+ XML.SubElement(
+ recipient_providers,
+ "hudson.plugins.emailext.plugins.recipients.DevelopersRecipientProvider",
+ ).text = ""
+ elif "requester" == recipient:
+ if recipient_providers is None:
+ recipient_providers = XML.SubElement(
+ email, "recipientProviders"
+ )
+ XML.SubElement(
+ recipient_providers,
+ "hudson.plugins.emailext.plugins.recipients.RequesterRecipientProvider",
+ ).text = ""
+ elif "culprits" == recipient:
+ if recipient_providers is None:
+ recipient_providers = XML.SubElement(
+ email, "recipientProviders"
+ )
+ XML.SubElement(
+ recipient_providers,
+ "hudson.plugins.emailext.plugins.recipients.CulpritsRecipientProvider",
+ ).text = ""
+ elif "recipients" == recipient:
+ if recipient_providers is None:
+ recipient_providers = XML.SubElement(
+ email, "recipientProviders"
+ )
+ XML.SubElement(
+ recipient_providers,
+ "hudson.plugins.emailext.plugins.recipients.ListRecipientProvider",
+ ).text = ""
+ elif "failing-test-suspects-recipients" == recipient:
+ if recipient_providers is None:
+ recipient_providers = XML.SubElement(
+ email, "recipientProviders"
+ )
+ XML.SubElement(
+ recipient_providers,
+ "hudson.plugins.emailext.plugins.recipients.FailingTestSuspectsRecipientProvider",
+ ).text = ""
+ elif "first-failing-build-suspects-recipients" == recipient:
+ if recipient_providers is None:
+ recipient_providers = XML.SubElement(
+ email, "recipientProviders"
+ )
+ XML.SubElement(
+ recipient_providers,
+ "hudson.plugins.emailext.plugins.recipients.FirstFailingBuildSuspectsRecipientProvider",
+ ).text = ""
+ # `failureCount` is deprecated and has no effect
+ # on email, but the element has been created
+ # in order to match the XML generated via UI.
+ failure_count_supporters = ["FirstFailureTrigger", "SecondFailureTrigger"]
+ if ttype in failure_count_supporters:
+ XML.SubElement(trigger, "failureCount").text = "0"
+ if "upstream-committers" in data["send-to"]:
+ if recipient_providers is None:
+ recipient_providers = XML.SubElement(email, "recipientProviders")
+ XML.SubElement(
+ recipient_providers,
+ "hudson.plugins.emailext.plugins.recipients.UpstreamComitterRecipientProvider",
+ ).text = ""
+ else:
+ if plugin_version < pkg_resources.parse_version("2.39"):
+ XML.SubElement(email, "sendToRequester").text = "false"
+ XML.SubElement(email, "sendToDevelopers").text = "false"
+ XML.SubElement(email, "includeCulprits").text = "false"
+ XML.SubElement(email, "sendToRecipientList").text = "true"
+ else:
recipient_providers = XML.SubElement(email, "recipientProviders")
XML.SubElement(
recipient_providers,
- "hudson.plugins.emailext.plugins.recipients.UpstreamComitterRecipientProvider",
+ "hudson.plugins.emailext.plugins.recipients.ListRecipientProvider",
).text = ""
- else:
- XML.SubElement(email, "sendToRequester").text = "false"
- XML.SubElement(email, "sendToDevelopers").text = "false"
- XML.SubElement(email, "includeCulprits").text = "false"
- XML.SubElement(email, "sendToRecipientList").text = "true"
+
if ttype == "ScriptTrigger":
XML.SubElement(trigger, "triggerScript").text = data["trigger-script"]
+ if plugin_version >= pkg_resources.parse_version("2.39"):
+ XML.SubElement(email, "attachmentsPattern").text = ""
+ XML.SubElement(email, "attachBuildLog").text = "false"
+ XML.SubElement(email, "compressBuildLog").text = "false"
+
def email_ext(registry, xml_parent, data):
"""yaml: email-ext
@@ -2501,6 +2588,8 @@ def email_ext(registry, xml_parent, data):
(default '$DEFAULT_RECIPIENTS')
:arg str reply-to: Comma separated list of email addresses that should be
in the Reply-To header for this project (default '$DEFAULT_REPLYTO')
+ :arg str from: Email address that should be
+ in the From header for this project (default '')
: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', 'both-html-text' or 'default'
@@ -2561,6 +2650,8 @@ def email_ext(registry, xml_parent, data):
* **culprits** (disabled by default)
* **recipients** (enabled by default)
* **upstream-committers** (>=2.39) (disabled by default)
+ * **failing-test-suspects-recipients** (>=2.39) (disabled by default)
+ * **first-failing-build-suspects-recipients** (>=2.39) (disabled by default)
Example:
@@ -2571,6 +2662,10 @@ def email_ext(registry, xml_parent, data):
emailext = XML.SubElement(
xml_parent, "hudson.plugins.emailext.ExtendedEmailPublisher"
)
+
+ info = registry.get_plugin_info("email-ext")
+ plugin_version = pkg_resources.parse_version(info.get("version", str(sys.maxsize)))
+
if "recipients" in data:
XML.SubElement(emailext, "recipientList").text = data["recipients"]
else:
@@ -2634,6 +2729,10 @@ def email_ext(registry, xml_parent, data):
("disable-publisher", "disabled", False),
("reply-to", "replyTo", "$DEFAULT_REPLYTO"),
]
+
+ if plugin_version >= pkg_resources.parse_version("2.39"):
+ mappings.append(("from", "from", ""))
+
helpers.convert_mapping_to_xml(emailext, data, mappings, fail_required=True)
matrix_dict = {
diff --git a/tests/publishers/fixtures/email-ext001.plugins_info.yaml b/tests/publishers/fixtures/email-ext001.plugins_info.yaml
new file mode 100644
index 000000000..f8e15c56b
--- /dev/null
+++ b/tests/publishers/fixtures/email-ext001.plugins_info.yaml
@@ -0,0 +1,3 @@
+- longName: 'Extended Email Publisher'
+ shortName: 'email-ext'
+ version: "2.38"
diff --git a/tests/publishers/fixtures/email-ext001.xml b/tests/publishers/fixtures/email-ext001.xml
index 48f3fc8a9..a735ad6f1 100644
--- a/tests/publishers/fixtures/email-ext001.xml
+++ b/tests/publishers/fixtures/email-ext001.xml
@@ -13,9 +13,6 @@
true
true
true
-
-
-
@@ -27,9 +24,6 @@
true
true
true
-
-
-
@@ -41,9 +35,6 @@
true
true
true
-
-
-
@@ -55,9 +46,6 @@
true
true
true
-
-
-
@@ -69,9 +57,6 @@
true
true
true
-
-
-
@@ -83,9 +68,6 @@
true
true
true
-
-
-
@@ -97,9 +79,6 @@
true
true
true
-
-
-
@@ -111,9 +90,6 @@
true
true
true
-
-
-
@@ -125,9 +101,6 @@
true
true
true
-
-
-
@@ -139,9 +112,6 @@
true
true
true
-
-
-
@@ -153,9 +123,6 @@
true
true
true
-
-
-
@@ -167,9 +134,6 @@
true
true
true
-
-
-
@@ -181,9 +145,6 @@
true
true
true
-
-
-
@@ -195,9 +156,6 @@
true
true
true
-
-
-
@@ -209,9 +167,6 @@
true
true
true
-
-
-
@@ -223,9 +178,6 @@
true
true
true
-
-
-
diff --git a/tests/publishers/fixtures/email-ext002.plugins_info.yaml b/tests/publishers/fixtures/email-ext002.plugins_info.yaml
new file mode 100644
index 000000000..f8e15c56b
--- /dev/null
+++ b/tests/publishers/fixtures/email-ext002.plugins_info.yaml
@@ -0,0 +1,3 @@
+- longName: 'Extended Email Publisher'
+ shortName: 'email-ext'
+ version: "2.38"
diff --git a/tests/publishers/fixtures/email-ext003.plugins_info.yaml b/tests/publishers/fixtures/email-ext003.plugins_info.yaml
new file mode 100644
index 000000000..f8e15c56b
--- /dev/null
+++ b/tests/publishers/fixtures/email-ext003.plugins_info.yaml
@@ -0,0 +1,3 @@
+- longName: 'Extended Email Publisher'
+ shortName: 'email-ext'
+ version: "2.38"
diff --git a/tests/publishers/fixtures/email-ext004.plugins_info.yaml b/tests/publishers/fixtures/email-ext004.plugins_info.yaml
new file mode 100644
index 000000000..38e9fcc3f
--- /dev/null
+++ b/tests/publishers/fixtures/email-ext004.plugins_info.yaml
@@ -0,0 +1,3 @@
+- longName: 'Extended Email Publisher'
+ shortName: 'email-ext'
+ version: "2.54"
diff --git a/tests/publishers/fixtures/email-ext004.xml b/tests/publishers/fixtures/email-ext004.xml
new file mode 100644
index 000000000..2dce3b76e
--- /dev/null
+++ b/tests/publishers/fixtures/email-ext004.xml
@@ -0,0 +1,345 @@
+
+
+
+
+ foo@example.com, bar@example.com
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+ 0
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+ 0
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+
+
+
+ text/html
+ Subject for Build ${BUILD_NUMBER}
+ The build has finished
+ */foo*.log
+ cancel=true
+ cancel=true
+ false
+ false
+ true
+ false
+ foo@example.com
+ lorem@ipsum.dolor
+ ONLY_CONFIGURATIONS
+
+
+
diff --git a/tests/publishers/fixtures/email-ext004.yaml b/tests/publishers/fixtures/email-ext004.yaml
new file mode 100644
index 000000000..bf32a2010
--- /dev/null
+++ b/tests/publishers/fixtures/email-ext004.yaml
@@ -0,0 +1,39 @@
+publishers:
+ - email-ext:
+ recipients: foo@example.com, bar@example.com
+ reply-to: foo@example.com
+ from: lorem@ipsum.dolor
+ content-type: html
+ subject: Subject for Build ${BUILD_NUMBER}
+ body: The build has finished
+ attach-build-log: false
+ compress-log: false
+ attachments: "*/foo*.log"
+ always: true
+ unstable: true
+ first-failure: true
+ first-unstable: true
+ not-built: true
+ aborted: true
+ regression: true
+ failure: true
+ second-failure: true
+ improvement: true
+ still-failing: true
+ success: true
+ fixed: true
+ fixed-unhealthy: true
+ still-unstable: true
+ pre-build: true
+ matrix-trigger: only-configurations
+ presend-script: "cancel=true"
+ postsend-script: "cancel=true"
+ save-output: true
+ send-to:
+ - developers
+ - requester
+ - culprits
+ - recipients
+ - upstream-committers
+ - failing-test-suspects-recipients
+ - first-failing-build-suspects-recipients
diff --git a/tests/publishers/fixtures/email-ext005.plugins_info.yaml b/tests/publishers/fixtures/email-ext005.plugins_info.yaml
new file mode 100644
index 000000000..38e9fcc3f
--- /dev/null
+++ b/tests/publishers/fixtures/email-ext005.plugins_info.yaml
@@ -0,0 +1,3 @@
+- longName: 'Extended Email Publisher'
+ shortName: 'email-ext'
+ version: "2.54"
diff --git a/tests/publishers/fixtures/email-ext005.xml b/tests/publishers/fixtures/email-ext005.xml
new file mode 100644
index 000000000..37951fa0c
--- /dev/null
+++ b/tests/publishers/fixtures/email-ext005.xml
@@ -0,0 +1,65 @@
+
+
+
+
+ foo@example.com, bar@example.com
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+ false
+ false
+
+
+
+
+ $PROJECT_DEFAULT_SUBJECT
+ $PROJECT_DEFAULT_CONTENT
+ $PROJECT_DEFAULT_REPLYTO
+ project
+
+
+
+
+ false
+ false
+
+
+
+ text/html
+ Subject for Build ${BUILD_NUMBER}
+ The build has finished
+ */foo*.log
+ cancel=true
+ cancel=true
+ false
+ false
+ true
+ false
+ foo@example.com
+ lorem@ipsum.dolor
+ ONLY_CONFIGURATIONS
+
+
+
diff --git a/tests/publishers/fixtures/email-ext005.yaml b/tests/publishers/fixtures/email-ext005.yaml
new file mode 100644
index 000000000..4d333dee5
--- /dev/null
+++ b/tests/publishers/fixtures/email-ext005.yaml
@@ -0,0 +1,17 @@
+publishers:
+ - email-ext:
+ recipients: foo@example.com, bar@example.com
+ reply-to: foo@example.com
+ from: lorem@ipsum.dolor
+ content-type: html
+ subject: Subject for Build ${BUILD_NUMBER}
+ body: The build has finished
+ attach-build-log: false
+ compress-log: false
+ attachments: "*/foo*.log"
+ always: true
+ unstable: true
+ matrix-trigger: only-configurations
+ presend-script: "cancel=true"
+ postsend-script: "cancel=true"
+ save-output: true
diff --git a/tests/yamlparser/fixtures/template_override_project_level_defaults.plugins_info.yaml b/tests/yamlparser/fixtures/template_override_project_level_defaults.plugins_info.yaml
new file mode 100644
index 000000000..f8e15c56b
--- /dev/null
+++ b/tests/yamlparser/fixtures/template_override_project_level_defaults.plugins_info.yaml
@@ -0,0 +1,3 @@
+- longName: 'Extended Email Publisher'
+ shortName: 'email-ext'
+ version: "2.38"