Refactor clone_workspace function to use convert_mapping_to_xml
1. Refactored the code in the function to utilize convert_mapping_to_xml's way of detecting valid types. 2. Refactored optional parameters to use convert_mapping_to_xml Note: This update will affect users using lowercase inputs in their YAML files. An exception will be raised if the inputs doesn't follow the exact casing required by the plugin. Change-Id: I053ef5f58200e51b3f6ff5ec55760f9e6f095370
This commit is contained in:
parent
746a089d4a
commit
9ab35beae8
@ -638,39 +638,23 @@ def clone_workspace(registry, xml_parent, data):
|
||||
'hudson.plugins.cloneworkspace.CloneWorkspacePublisher')
|
||||
cloneworkspace.set('plugin', 'clone-workspace-scm')
|
||||
|
||||
criteria_valid_types = ['Any', 'Not Failed', 'Successful']
|
||||
archive_valid_types = ['TAR', 'ZIP']
|
||||
|
||||
mappings = [
|
||||
('workspace-glob', 'workspaceGlob', ''),
|
||||
('override-default-excludes', 'overrideDefaultExcludes', False),
|
||||
('criteria', 'criteria', 'Any', criteria_valid_types),
|
||||
('archive-method', 'archiveMethod', 'TAR', archive_valid_types),
|
||||
]
|
||||
helpers.convert_mapping_to_xml(
|
||||
cloneworkspace, data, mappings, fail_required=True)
|
||||
|
||||
if 'workspace-exclude-glob' in data:
|
||||
XML.SubElement(
|
||||
cloneworkspace,
|
||||
'workspaceExcludeGlob').text = data['workspace-exclude-glob']
|
||||
|
||||
criteria_list = ['Any', 'Not Failed', 'Successful']
|
||||
|
||||
criteria = data.get('criteria', 'Any').title()
|
||||
|
||||
if 'criteria' in data and criteria not in criteria_list:
|
||||
raise JenkinsJobsException(
|
||||
'clone-workspace criteria must be one of: ' +
|
||||
', '.join(criteria_list))
|
||||
else:
|
||||
XML.SubElement(cloneworkspace, 'criteria').text = criteria
|
||||
|
||||
archive_list = ['TAR', 'ZIP']
|
||||
|
||||
archive_method = data.get('archive-method', 'TAR').upper()
|
||||
|
||||
if 'archive-method' in data and archive_method not in archive_list:
|
||||
raise JenkinsJobsException(
|
||||
'clone-workspace archive-method must be one of: ' +
|
||||
', '.join(archive_list))
|
||||
else:
|
||||
XML.SubElement(cloneworkspace, 'archiveMethod').text = archive_method
|
||||
mappings = [
|
||||
('workspace-exclude-glob', 'workspaceExcludeGlob', ''),
|
||||
]
|
||||
helpers.convert_mapping_to_xml(
|
||||
cloneworkspace, data, mappings, fail_required=False)
|
||||
|
||||
|
||||
def cloud_foundry(parser, xml_parent, data):
|
||||
|
@ -6,6 +6,7 @@
|
||||
<overrideDefaultExcludes>false</overrideDefaultExcludes>
|
||||
<criteria>Any</criteria>
|
||||
<archiveMethod>TAR</archiveMethod>
|
||||
<workspaceExcludeGlob/>
|
||||
</hudson.plugins.cloneworkspace.CloneWorkspacePublisher>
|
||||
</publishers>
|
||||
</project>
|
||||
|
@ -4,9 +4,9 @@
|
||||
<hudson.plugins.cloneworkspace.CloneWorkspacePublisher plugin="clone-workspace-scm">
|
||||
<workspaceGlob>**/*.zip</workspaceGlob>
|
||||
<overrideDefaultExcludes>false</overrideDefaultExcludes>
|
||||
<workspaceExcludeGlob>**/*.tgz</workspaceExcludeGlob>
|
||||
<criteria>Any</criteria>
|
||||
<archiveMethod>TAR</archiveMethod>
|
||||
<workspaceExcludeGlob>**/*.tgz</workspaceExcludeGlob>
|
||||
</hudson.plugins.cloneworkspace.CloneWorkspacePublisher>
|
||||
</publishers>
|
||||
</project>
|
||||
|
@ -1,7 +1,7 @@
|
||||
publishers:
|
||||
- clone-workspace:
|
||||
criteria: "any"
|
||||
archive-method: "tar"
|
||||
criteria: "Any"
|
||||
archive-method: "TAR"
|
||||
override-default-excludes: false
|
||||
workspace-glob: "**/*.zip"
|
||||
workspace-exclude-glob: "**/*.tgz"
|
||||
|
Loading…
Reference in New Issue
Block a user