From 2a5acc24d6c599023978c3904992f598d722a597 Mon Sep 17 00:00:00 2001 From: Eren ATAS Date: Tue, 15 Sep 2020 13:26:11 +0200 Subject: [PATCH] Updated Email Extended Publisher Plugin Parameters inside triggers were not updated while the upper parameters were changed, were staying as default. Updated the implementation to make it take from the upper level. Change-Id: I16fc3525fcdf0a8bf3aea3b8422f0f2ad26f9e24 Signed-off-by: Eren ATAS --- jenkins_jobs/modules/publishers.py | 10 +- tests/publishers/fixtures/email-ext004.xml | 100 ++++++++++---------- tests/publishers/fixtures/email-ext004.yaml | 4 +- tests/publishers/fixtures/email-ext005.xml | 6 +- 4 files changed, 62 insertions(+), 58 deletions(-) diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index c9ccfb553..e06144ab3 100755 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -2567,9 +2567,13 @@ def base_email_ext(registry, xml_parent, data, ttype): 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" + mappings = [ + ("attachments", "attachmentsPattern", ""), + ("attach-build-log", "attachBuildLog", False), + ("compress-log", "compressBuildLog", False), + ] + + helpers.convert_mapping_to_xml(email, data, mappings, fail_required=True) def email_ext(registry, xml_parent, data): diff --git a/tests/publishers/fixtures/email-ext004.xml b/tests/publishers/fixtures/email-ext004.xml index 2dce3b76e..71809b6af 100644 --- a/tests/publishers/fixtures/email-ext004.xml +++ b/tests/publishers/fixtures/email-ext004.xml @@ -19,9 +19,9 @@ - - false - false + */foo*.log + true + true @@ -39,9 +39,9 @@ - - false - false + */foo*.log + true + true @@ -59,9 +59,9 @@ - - false - false + */foo*.log + true + true 0 @@ -80,9 +80,9 @@ - - false - false + */foo*.log + true + true @@ -100,9 +100,9 @@ - - false - false + */foo*.log + true + true @@ -120,9 +120,9 @@ - - false - false + */foo*.log + true + true @@ -140,9 +140,9 @@ - - false - false + */foo*.log + true + true @@ -160,9 +160,9 @@ - - false - false + */foo*.log + true + true @@ -180,9 +180,9 @@ - - false - false + */foo*.log + true + true 0 @@ -201,9 +201,9 @@ - - false - false + */foo*.log + true + true @@ -221,9 +221,9 @@ - - false - false + */foo*.log + true + true @@ -241,9 +241,9 @@ - - false - false + */foo*.log + true + true @@ -261,9 +261,9 @@ - - false - false + */foo*.log + true + true @@ -281,9 +281,9 @@ - - false - false + */foo*.log + true + true @@ -301,9 +301,9 @@ - - false - false + */foo*.log + true + true @@ -321,9 +321,9 @@ - - false - false + */foo*.log + true + true @@ -333,8 +333,8 @@ */foo*.log cancel=true cancel=true - false - false + true + true true false foo@example.com diff --git a/tests/publishers/fixtures/email-ext004.yaml b/tests/publishers/fixtures/email-ext004.yaml index bf32a2010..f0751a3db 100644 --- a/tests/publishers/fixtures/email-ext004.yaml +++ b/tests/publishers/fixtures/email-ext004.yaml @@ -6,8 +6,8 @@ publishers: content-type: html subject: Subject for Build ${BUILD_NUMBER} body: The build has finished - attach-build-log: false - compress-log: false + attach-build-log: true + compress-log: true attachments: "*/foo*.log" always: true unstable: true diff --git a/tests/publishers/fixtures/email-ext005.xml b/tests/publishers/fixtures/email-ext005.xml index 37951fa0c..e66bfa66d 100644 --- a/tests/publishers/fixtures/email-ext005.xml +++ b/tests/publishers/fixtures/email-ext005.xml @@ -13,7 +13,7 @@ - + */foo*.log false false @@ -27,7 +27,7 @@ - + */foo*.log false false @@ -41,7 +41,7 @@ - + */foo*.log false false