From 0583e30dc455a4f905f7598bc144dce1676bec74 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Thu, 9 Feb 2017 20:32:07 -0500 Subject: [PATCH] Use convert_mapping_to_xml for CAV plugin - Update docs - Update minimal and full tests - Use convert_mapping_to_xml Change-Id: I05e6945055e6a6e9a358377d7e2fc00944f1f9cc Signed-off-by: Thanh Ha --- jenkins_jobs/modules/builders.py | 18 +++++++++++++----- ...n001.xml => changeassemblyversion-full.xml} | 0 ...01.yaml => changeassemblyversion-full.yaml} | 0 ...2.xml => changeassemblyversion-minimal.xml} | 2 +- .../changeassemblyversion-minimal.yaml | 2 ++ .../fixtures/changeassemblyversion002.yaml | 3 --- 6 files changed, 16 insertions(+), 9 deletions(-) rename tests/builders/fixtures/{changeassemblyversion001.xml => changeassemblyversion-full.xml} (100%) rename tests/builders/fixtures/{changeassemblyversion001.yaml => changeassemblyversion-full.yaml} (100%) rename tests/builders/fixtures/{changeassemblyversion002.xml => changeassemblyversion-minimal.xml} (91%) create mode 100644 tests/builders/fixtures/changeassemblyversion-minimal.yaml delete mode 100644 tests/builders/fixtures/changeassemblyversion002.yaml diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py index dc9a90d21..57c932b69 100644 --- a/jenkins_jobs/modules/builders.py +++ b/jenkins_jobs/modules/builders.py @@ -189,19 +189,27 @@ def change_assembly_version(registry, xml_parent, data): :arg str version: Set the new version number for replace (default 1.0.0) :arg str assemblyFile: The file name to search (default AssemblyInfo.cs) - Example: + Minimal Example: .. literalinclude:: - /../../tests/builders/fixtures/changeassemblyversion001.yaml + /../../tests/builders/fixtures/changeassemblyversion-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: + /../../tests/builders/fixtures/changeassemblyversion-full.yaml :language: yaml """ cav_builder_tag = ('org.jenkinsci.plugins.changeassemblyversion.' 'ChangeAssemblyVersion') cav = XML.SubElement(xml_parent, cav_builder_tag) - XML.SubElement(cav, 'task').text = data.get('version', '1.0.0') - XML.SubElement(cav, 'assemblyFile').text = str( - data.get('assembly-file', 'AssemblyInfo.cs')) + mappings = [ + ('version', 'task', '1.0.0'), + ('assembly-file', 'assemblyFile', 'AssemblyInfo.cs'), + ] + convert_mapping_to_xml(cav, data, mappings, fail_required=True) def fingerprint(registry, xml_parent, data): diff --git a/tests/builders/fixtures/changeassemblyversion001.xml b/tests/builders/fixtures/changeassemblyversion-full.xml similarity index 100% rename from tests/builders/fixtures/changeassemblyversion001.xml rename to tests/builders/fixtures/changeassemblyversion-full.xml diff --git a/tests/builders/fixtures/changeassemblyversion001.yaml b/tests/builders/fixtures/changeassemblyversion-full.yaml similarity index 100% rename from tests/builders/fixtures/changeassemblyversion001.yaml rename to tests/builders/fixtures/changeassemblyversion-full.yaml diff --git a/tests/builders/fixtures/changeassemblyversion002.xml b/tests/builders/fixtures/changeassemblyversion-minimal.xml similarity index 91% rename from tests/builders/fixtures/changeassemblyversion002.xml rename to tests/builders/fixtures/changeassemblyversion-minimal.xml index 75b79afa1..51d34894f 100644 --- a/tests/builders/fixtures/changeassemblyversion002.xml +++ b/tests/builders/fixtures/changeassemblyversion-minimal.xml @@ -2,7 +2,7 @@ - 9.9.9 + 1.0.0 AssemblyInfo.cs diff --git a/tests/builders/fixtures/changeassemblyversion-minimal.yaml b/tests/builders/fixtures/changeassemblyversion-minimal.yaml new file mode 100644 index 000000000..0b1291989 --- /dev/null +++ b/tests/builders/fixtures/changeassemblyversion-minimal.yaml @@ -0,0 +1,2 @@ +builders: + - change-assembly-version diff --git a/tests/builders/fixtures/changeassemblyversion002.yaml b/tests/builders/fixtures/changeassemblyversion002.yaml deleted file mode 100644 index 3a7d1afa9..000000000 --- a/tests/builders/fixtures/changeassemblyversion002.yaml +++ /dev/null @@ -1,3 +0,0 @@ -builders: - - change-assembly-version: - version: "9.9.9"