diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index db4bd8ad3..f3986ece7 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -4550,35 +4550,40 @@ def description_setter(registry, xml_parent, data): <Description+Setter+Plugin>`. :arg str regexp: A RegEx which is used to scan the build log file + (default '') :arg str regexp-for-failed: A RegEx which is used for failed builds - (optional) + (default '') :arg str description: The description to set on the build (optional) :arg str description-for-failed: The description to set on the failed builds (optional) :arg bool set-for-matrix: Also set the description on a multi-configuration build (default false) - Example: + Minimal Example: .. literalinclude:: - /../../tests/publishers/fixtures/description-setter001.yaml + /../../tests/publishers/fixtures/description-setter-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: + /../../tests/publishers/fixtures/description-setter-full.yaml :language: yaml """ descriptionsetter = XML.SubElement( xml_parent, 'hudson.plugins.descriptionsetter.DescriptionSetterPublisher') - XML.SubElement(descriptionsetter, 'regexp').text = data.get('regexp', '') - XML.SubElement(descriptionsetter, 'regexpForFailed').text = \ - data.get('regexp-for-failed', '') - if 'description' in data: - XML.SubElement(descriptionsetter, 'description').text = \ - data['description'] - if 'description-for-failed' in data: - XML.SubElement(descriptionsetter, 'descriptionForFailed').text = \ - data['description-for-failed'] - for_matrix = str(data.get('set-for-matrix', False)).lower() - XML.SubElement(descriptionsetter, 'setForMatrix').text = for_matrix + mappings = [ + ('regexp', 'regexp', ''), + ('regexp-for-failed', 'regexpForFailed', ''), + ('description', 'description', None), + ('description-for-failed', 'descriptionForFailed', None), + ('set-for-matrix', 'setForMatrix', False) + ] + helpers.convert_mapping_to_xml( + descriptionsetter, data, mappings, fail_required=False) def doxygen(registry, xml_parent, data): diff --git a/tests/publishers/fixtures/description-setter001.xml b/tests/publishers/fixtures/description-setter-full.xml similarity index 100% rename from tests/publishers/fixtures/description-setter001.xml rename to tests/publishers/fixtures/description-setter-full.xml diff --git a/tests/publishers/fixtures/description-setter001.yaml b/tests/publishers/fixtures/description-setter-full.yaml similarity index 100% rename from tests/publishers/fixtures/description-setter001.yaml rename to tests/publishers/fixtures/description-setter-full.yaml diff --git a/tests/publishers/fixtures/description-setter-minimal.xml b/tests/publishers/fixtures/description-setter-minimal.xml new file mode 100644 index 000000000..0e1de76d1 --- /dev/null +++ b/tests/publishers/fixtures/description-setter-minimal.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <publishers> + <hudson.plugins.descriptionsetter.DescriptionSetterPublisher> + <regexp/> + <regexpForFailed/> + <setForMatrix>false</setForMatrix> + </hudson.plugins.descriptionsetter.DescriptionSetterPublisher> + </publishers> +</project> diff --git a/tests/publishers/fixtures/description-setter-minimal.yaml b/tests/publishers/fixtures/description-setter-minimal.yaml new file mode 100644 index 000000000..8a63c3717 --- /dev/null +++ b/tests/publishers/fixtures/description-setter-minimal.yaml @@ -0,0 +1,2 @@ +publishers: + - description-setter diff --git a/tests/publishers/fixtures/description-setter002.xml b/tests/publishers/fixtures/description-setter002.xml deleted file mode 100644 index 23f5d9122..000000000 --- a/tests/publishers/fixtures/description-setter002.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<project> - <publishers> - <hudson.plugins.descriptionsetter.DescriptionSetterPublisher> - <regexp>.*(<a href=.*a>)</regexp> - <regexpForFailed>.*(<a href=.*a>)</regexpForFailed> - <description>こんにちは</description> - <descriptionForFailed>さようなら</descriptionForFailed> - <setForMatrix>true</setForMatrix> - </hudson.plugins.descriptionsetter.DescriptionSetterPublisher> - </publishers> -</project> diff --git a/tests/publishers/fixtures/description-setter002.yaml b/tests/publishers/fixtures/description-setter002.yaml deleted file mode 100644 index 7e6e70185..000000000 --- a/tests/publishers/fixtures/description-setter002.yaml +++ /dev/null @@ -1,7 +0,0 @@ -publishers: - - description-setter: - regexp: ".*(<a href=.*a>)" - regexp-for-failed: ".*(<a href=.*a>)" - description: "こんにちは" - description-for-failed: "さようなら" - set-for-matrix: true