jclouds: Utilize convert_mapping_to_xml

Change-Id: I319aee86daf63f17778f020dea6b3756db04127d
Co-Authored-By: Anil Belur <askb23@gmail.com>
Signed-off-by: Tan Heng Yeow <E0032242@u.nus.edu>
Signed-off-by: Anil Belur <askb23@gmail.com>
This commit is contained in:
tanhengyeow 2018-09-14 21:35:24 +08:00 committed by Thanh Ha (zxiiro)
parent 539d13e816
commit e46a3be4fe
3 changed files with 13 additions and 14 deletions

View File

@ -186,28 +186,27 @@ def jclouds(registry, xml_parent, data):
deployer = XML.SubElement(xml_parent,
'jenkins.plugins.jclouds.blobstore.'
'BlobStorePublisher')
if 'profile' not in data:
raise JenkinsJobsException('profile parameter is missing')
XML.SubElement(deployer, 'profileName').text = data.get('profile')
entries = XML.SubElement(deployer, 'entries')
deployer_entry = XML.SubElement(entries,
'jenkins.plugins.jclouds.blobstore.'
'BlobStoreEntry')
deployer_mapping = [
('profile', 'profileName', None),
]
helpers.convert_mapping_to_xml(
deployer, data, deployer_mapping, fail_required=True)
try:
XML.SubElement(deployer_entry, 'container').text = data['container']
XML.SubElement(deployer_entry, 'path').text = data.get('basedir', '')
XML.SubElement(deployer_entry, 'sourceFile').text = data['files']
except KeyError as e:
raise JenkinsJobsException("blobstore requires '%s' to be set"
% e.args[0])
mapping = [('hierarchy', 'keepHierarchy', False)]
deployer_entry_mapping = [
('hierarchy', 'keepHierarchy', False),
('basedir', 'path', ''),
]
helpers.convert_mapping_to_xml(
deployer_entry, data, mapping, fail_required=True)
deployer_entry, data, deployer_entry_mapping, fail_required=True)
def javadoc(registry, xml_parent, data):

View File

@ -2,15 +2,15 @@
<project>
<publishers>
<jenkins.plugins.jclouds.blobstore.BlobStorePublisher>
<profileName>hp</profileName>
<entries>
<jenkins.plugins.jclouds.blobstore.BlobStoreEntry>
<container>jenkins</container>
<path/>
<sourceFile>*.tar.gz</sourceFile>
<keepHierarchy>false</keepHierarchy>
<path>test base dir</path>
</jenkins.plugins.jclouds.blobstore.BlobStoreEntry>
</entries>
<profileName>hp</profileName>
</jenkins.plugins.jclouds.blobstore.BlobStorePublisher>
</publishers>
</project>

View File

@ -3,4 +3,4 @@ publishers:
profile: hp
files: '*.tar.gz'
container: jenkins
basedir:
basedir: test base dir