diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py
index b8a085d09..34484654a 100644
--- a/jenkins_jobs/modules/publishers.py
+++ b/jenkins_jobs/modules/publishers.py
@@ -63,44 +63,19 @@ def archive(registry, xml_parent, data):
.. literalinclude:: /../../tests/publishers/fixtures/archive001.yaml
:language: yaml
"""
- logger = logging.getLogger("%s:archive" % __name__)
archiver = XML.SubElement(xml_parent, 'hudson.tasks.ArtifactArchiver')
- artifacts = XML.SubElement(archiver, 'artifacts')
- artifacts.text = data['artifacts']
+ mapping = [
+ ('artifacts', 'artifacts', None),
+ ('allow-empty', 'allowEmptyArchive', False),
+ ('only-if-success', 'onlyIfSuccessful', False),
+ ('fingerprint', 'fingerprint', False),
+ ('default-excludes', 'defaultExcludes', True),
+ ('case-sensitive', 'caseSensitive', True),
+ ('latest-only', 'latestOnly', False)]
+
if 'excludes' in data:
- excludes = XML.SubElement(archiver, 'excludes')
- excludes.text = data['excludes']
- latest = XML.SubElement(archiver, 'latestOnly')
- # backward compatibility
- latest_only = data.get('latest_only', False)
- if 'latest_only' in data:
- logger.warning('latest_only is deprecated please use latest-only')
- if 'latest-only' in data:
- latest_only = data['latest-only']
- if latest_only:
- latest.text = 'true'
- else:
- latest.text = 'false'
-
- if 'allow-empty' in data:
- empty = XML.SubElement(archiver, 'allowEmptyArchive')
- # Default behavior is to fail the build.
- empty.text = str(data.get('allow-empty', False)).lower()
-
- if 'only-if-success' in data:
- success = XML.SubElement(archiver, 'onlyIfSuccessful')
- success.text = str(data.get('only-if-success', False)).lower()
-
- if 'fingerprint' in data:
- fingerprint = XML.SubElement(archiver, 'fingerprint')
- fingerprint.text = str(data.get('fingerprint', False)).lower()
-
- default_excludes = XML.SubElement(archiver, 'defaultExcludes')
- default_excludes.text = str(data.get('default-excludes', True)).lower()
-
- if 'case-sensitive' in data:
- case_sensitive = XML.SubElement(archiver, 'caseSensitive')
- case_sensitive.text = str(data.get('case-sensitive', True)).lower()
+ mapping.append(('excludes', 'excludes', None))
+ helpers.convert_mapping_to_xml(archiver, data, mapping, fail_required=True)
def blame_upstream(registry, xml_parent, data):
diff --git a/tests/publishers/fixtures/archive001.xml b/tests/publishers/fixtures/archive001.xml
index 7c49faefe..e95aac653 100644
--- a/tests/publishers/fixtures/archive001.xml
+++ b/tests/publishers/fixtures/archive001.xml
@@ -3,10 +3,12 @@
*.tar.gz
- false
true
+ false
true
false
+ true
+ false
diff --git a/tests/publishers/fixtures/archive002.xml b/tests/publishers/fixtures/archive002.xml
index f06accfee..8d48f9460 100644
--- a/tests/publishers/fixtures/archive002.xml
+++ b/tests/publishers/fixtures/archive002.xml
@@ -3,11 +3,13 @@
*.tar.gz
- false
true
true
true
true
+ true
+ false
+ path
diff --git a/tests/publishers/fixtures/archive002.yaml b/tests/publishers/fixtures/archive002.yaml
index e14fd20c7..b91526b38 100644
--- a/tests/publishers/fixtures/archive002.yaml
+++ b/tests/publishers/fixtures/archive002.yaml
@@ -4,3 +4,4 @@ publishers:
allow-empty: true
only-if-success: true
fingerprint: true
+ excludes: path
diff --git a/tests/publishers/fixtures/archive003.xml b/tests/publishers/fixtures/archive003.xml
index 4ce5ff6e9..0b9747362 100644
--- a/tests/publishers/fixtures/archive003.xml
+++ b/tests/publishers/fixtures/archive003.xml
@@ -3,12 +3,12 @@
*.tar.gz
- false
true
false
true
true
false
+ false
diff --git a/tests/publishers/fixtures/conditional-publisher001.xml b/tests/publishers/fixtures/conditional-publisher001.xml
index 99b324350..f0b1a224b 100644
--- a/tests/publishers/fixtures/conditional-publisher001.xml
+++ b/tests/publishers/fixtures/conditional-publisher001.xml
@@ -21,9 +21,12 @@
**/**
- false
true
+ false
+ false
true
+ true
+ false
diff --git a/tests/publishers/fixtures/conditional-publisher003.xml b/tests/publishers/fixtures/conditional-publisher003.xml
index 46197b9e2..8da31ea8a 100644
--- a/tests/publishers/fixtures/conditional-publisher003.xml
+++ b/tests/publishers/fixtures/conditional-publisher003.xml
@@ -9,9 +9,12 @@
**/**
- false
true
+ false
+ false
true
+ true
+ false
true
diff --git a/tests/publishers/fixtures/conditional-publisher004.xml b/tests/publishers/fixtures/conditional-publisher004.xml
index fec92f7dd..91a2e633b 100644
--- a/tests/publishers/fixtures/conditional-publisher004.xml
+++ b/tests/publishers/fixtures/conditional-publisher004.xml
@@ -11,9 +11,12 @@
**/**
- false
true
+ false
+ false
true
+ true
+ false