Merge "Refactor clone_workspace function to use convert_mapping_to_xml"
This commit is contained in:
commit
3b777009f3
|
@ -638,39 +638,23 @@ def clone_workspace(registry, xml_parent, data):
|
||||||
'hudson.plugins.cloneworkspace.CloneWorkspacePublisher')
|
'hudson.plugins.cloneworkspace.CloneWorkspacePublisher')
|
||||||
cloneworkspace.set('plugin', 'clone-workspace-scm')
|
cloneworkspace.set('plugin', 'clone-workspace-scm')
|
||||||
|
|
||||||
|
criteria_valid_types = ['Any', 'Not Failed', 'Successful']
|
||||||
|
archive_valid_types = ['TAR', 'ZIP']
|
||||||
|
|
||||||
mappings = [
|
mappings = [
|
||||||
('workspace-glob', 'workspaceGlob', ''),
|
('workspace-glob', 'workspaceGlob', ''),
|
||||||
('override-default-excludes', 'overrideDefaultExcludes', False),
|
('override-default-excludes', 'overrideDefaultExcludes', False),
|
||||||
|
('criteria', 'criteria', 'Any', criteria_valid_types),
|
||||||
|
('archive-method', 'archiveMethod', 'TAR', archive_valid_types),
|
||||||
]
|
]
|
||||||
helpers.convert_mapping_to_xml(
|
helpers.convert_mapping_to_xml(
|
||||||
cloneworkspace, data, mappings, fail_required=True)
|
cloneworkspace, data, mappings, fail_required=True)
|
||||||
|
|
||||||
if 'workspace-exclude-glob' in data:
|
mappings = [
|
||||||
XML.SubElement(
|
('workspace-exclude-glob', 'workspaceExcludeGlob', ''),
|
||||||
cloneworkspace,
|
]
|
||||||
'workspaceExcludeGlob').text = data['workspace-exclude-glob']
|
helpers.convert_mapping_to_xml(
|
||||||
|
cloneworkspace, data, mappings, fail_required=False)
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
def cloud_foundry(parser, xml_parent, data):
|
def cloud_foundry(parser, xml_parent, data):
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<overrideDefaultExcludes>false</overrideDefaultExcludes>
|
<overrideDefaultExcludes>false</overrideDefaultExcludes>
|
||||||
<criteria>Any</criteria>
|
<criteria>Any</criteria>
|
||||||
<archiveMethod>TAR</archiveMethod>
|
<archiveMethod>TAR</archiveMethod>
|
||||||
|
<workspaceExcludeGlob/>
|
||||||
</hudson.plugins.cloneworkspace.CloneWorkspacePublisher>
|
</hudson.plugins.cloneworkspace.CloneWorkspacePublisher>
|
||||||
</publishers>
|
</publishers>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
<hudson.plugins.cloneworkspace.CloneWorkspacePublisher plugin="clone-workspace-scm">
|
<hudson.plugins.cloneworkspace.CloneWorkspacePublisher plugin="clone-workspace-scm">
|
||||||
<workspaceGlob>**/*.zip</workspaceGlob>
|
<workspaceGlob>**/*.zip</workspaceGlob>
|
||||||
<overrideDefaultExcludes>false</overrideDefaultExcludes>
|
<overrideDefaultExcludes>false</overrideDefaultExcludes>
|
||||||
<workspaceExcludeGlob>**/*.tgz</workspaceExcludeGlob>
|
|
||||||
<criteria>Any</criteria>
|
<criteria>Any</criteria>
|
||||||
<archiveMethod>TAR</archiveMethod>
|
<archiveMethod>TAR</archiveMethod>
|
||||||
|
<workspaceExcludeGlob>**/*.tgz</workspaceExcludeGlob>
|
||||||
</hudson.plugins.cloneworkspace.CloneWorkspacePublisher>
|
</hudson.plugins.cloneworkspace.CloneWorkspacePublisher>
|
||||||
</publishers>
|
</publishers>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
publishers:
|
publishers:
|
||||||
- clone-workspace:
|
- clone-workspace:
|
||||||
criteria: "any"
|
criteria: "Any"
|
||||||
archive-method: "tar"
|
archive-method: "TAR"
|
||||||
override-default-excludes: false
|
override-default-excludes: false
|
||||||
workspace-glob: "**/*.zip"
|
workspace-glob: "**/*.zip"
|
||||||
workspace-exclude-glob: "**/*.tgz"
|
workspace-exclude-glob: "**/*.tgz"
|
||||||
|
|
Loading…
Reference in New Issue