Update google_cloud_storage to use convert_xml()
Update tests Change-Id: Id3b65f58aac60f1ea43459fe14bba7456e8a1cf7
This commit is contained in:
parent
de631d49d3
commit
895ceea792
@ -5869,20 +5869,18 @@ def google_cloud_storage(registry, xml_parent, data):
|
||||
"""
|
||||
|
||||
def expiring_elements(properties, upload_element, types):
|
||||
"""Handle expiring elements upload action
|
||||
"""
|
||||
# Handle expiring elements upload action
|
||||
|
||||
xml_element = XML.SubElement(upload_element, 'com.google.'
|
||||
'jenkins.plugins.storage.'
|
||||
'ExpiringBucketLifecycleManager')
|
||||
|
||||
if 'bucket-name' not in properties:
|
||||
raise MissingAttributeError('bucket-name')
|
||||
XML.SubElement(xml_element, 'bucketNameWithVars').text = str(
|
||||
properties['bucket-name'])
|
||||
|
||||
XML.SubElement(xml_element, 'sharedPublicly').text = 'false'
|
||||
XML.SubElement(xml_element, 'forFailedJobs').text = 'false'
|
||||
mapping = [
|
||||
('bucket-name', 'bucketNameWithVars', None),
|
||||
('', 'sharedPublicly', False),
|
||||
('', 'forFailedJobs', False),
|
||||
('days-to-retain', 'bucketObjectTTL', None)]
|
||||
helpers.convert_mapping_to_xml(
|
||||
xml_element, properties, mapping, fail_required=True)
|
||||
|
||||
if types.count('expiring-elements') > 1:
|
||||
XML.SubElement(xml_element, 'module',
|
||||
@ -5891,34 +5889,20 @@ def google_cloud_storage(registry, xml_parent, data):
|
||||
else:
|
||||
XML.SubElement(xml_element, 'module')
|
||||
|
||||
if 'days-to-retain' not in properties:
|
||||
raise MissingAttributeError('days-to-retain')
|
||||
XML.SubElement(xml_element, 'bucketObjectTTL').text = str(
|
||||
properties['days-to-retain'])
|
||||
|
||||
def build_log(properties, upload_element, types):
|
||||
"""Handle build log upload action
|
||||
"""
|
||||
# Handle build log upload action
|
||||
|
||||
xml_element = XML.SubElement(upload_element, 'com.google.jenkins.'
|
||||
'plugins.storage.StdoutUpload')
|
||||
|
||||
if 'storage-location' not in properties:
|
||||
raise MissingAttributeError('storage-location')
|
||||
XML.SubElement(xml_element, 'bucketNameWithVars').text = str(
|
||||
properties['storage-location'])
|
||||
|
||||
XML.SubElement(xml_element, 'sharedPublicly').text = str(
|
||||
properties.get('share-publicly', False)).lower()
|
||||
|
||||
XML.SubElement(xml_element, 'forFailedJobs').text = str(
|
||||
properties.get('upload-for-failed-jobs', False)).lower()
|
||||
|
||||
XML.SubElement(xml_element, 'showInline').text = str(
|
||||
properties.get('show-inline', True)).lower()
|
||||
|
||||
XML.SubElement(xml_element, 'pathPrefix').text = str(
|
||||
properties.get('strip-prefix', ''))
|
||||
mapping = [
|
||||
('storage-location', 'bucketNameWithVars', None),
|
||||
('share-publicly', 'sharedPublicly', False),
|
||||
('upload-for-failed-jobs', 'forFailedJobs', False),
|
||||
('show-inline', 'showInline', True),
|
||||
('strip-prefix', 'pathPrefix', ''),
|
||||
('log-name', 'logName', None)]
|
||||
helpers.convert_mapping_to_xml(
|
||||
xml_element, properties, mapping, fail_required=True)
|
||||
|
||||
if types.count('build-log') > 1:
|
||||
XML.SubElement(xml_element, 'module',
|
||||
@ -5927,34 +5911,20 @@ def google_cloud_storage(registry, xml_parent, data):
|
||||
else:
|
||||
XML.SubElement(xml_element, 'module')
|
||||
|
||||
if 'log-name' not in properties:
|
||||
raise MissingAttributeError('log-name')
|
||||
XML.SubElement(xml_element, 'logName').text = str(
|
||||
properties['log-name'])
|
||||
|
||||
def classic(properties, upload_element, types):
|
||||
"""Handle classic upload action
|
||||
"""
|
||||
# Handle classic upload action
|
||||
|
||||
xml_element = XML.SubElement(upload_element, 'com.google.jenkins.'
|
||||
'plugins.storage.ClassicUpload')
|
||||
|
||||
if 'storage-location' not in properties:
|
||||
raise MissingAttributeError('storage-location')
|
||||
XML.SubElement(xml_element, 'bucketNameWithVars').text = str(
|
||||
properties['storage-location'])
|
||||
|
||||
XML.SubElement(xml_element, 'sharedPublicly').text = str(
|
||||
properties.get('share-publicly', False)).lower()
|
||||
|
||||
XML.SubElement(xml_element, 'forFailedJobs').text = str(
|
||||
properties.get('upload-for-failed-jobs', False)).lower()
|
||||
|
||||
XML.SubElement(xml_element, 'showInline').text = str(
|
||||
properties.get('show-inline', False)).lower()
|
||||
|
||||
XML.SubElement(xml_element, 'pathPrefix').text = str(
|
||||
properties.get('strip-prefix', ''))
|
||||
mapping = [
|
||||
('storage-location', 'bucketNameWithVars', None),
|
||||
('share-publicly', 'sharedPublicly', False),
|
||||
('upload-for-failed-jobs', 'forFailedJobs', False),
|
||||
('show-inline', 'showInline', False),
|
||||
('strip-prefix', 'pathPrefix', ''),
|
||||
('file-pattern', 'sourceGlobWithVars', None)]
|
||||
helpers.convert_mapping_to_xml(
|
||||
xml_element, properties, mapping, fail_required=True)
|
||||
|
||||
if types.count('classic') > 1:
|
||||
XML.SubElement(xml_element, 'module',
|
||||
@ -5963,26 +5933,17 @@ def google_cloud_storage(registry, xml_parent, data):
|
||||
else:
|
||||
XML.SubElement(xml_element, 'module')
|
||||
|
||||
if 'file-pattern' not in properties:
|
||||
raise MissingAttributeError('file-pattern')
|
||||
XML.SubElement(xml_element, 'sourceGlobWithVars').text = str(
|
||||
properties['file-pattern'])
|
||||
|
||||
uploader = XML.SubElement(xml_parent,
|
||||
'com.google.jenkins.plugins.storage.'
|
||||
'GoogleCloudStorageUploader',
|
||||
{'plugin': 'google-storage-plugin'})
|
||||
|
||||
try:
|
||||
credentials_id = str(data['credentials-id'])
|
||||
except KeyError as e:
|
||||
raise MissingAttributeError(e.args[0])
|
||||
XML.SubElement(uploader, 'credentialsId').text = credentials_id
|
||||
mapping = [('credentials-id', 'credentialsId', None)]
|
||||
helpers.convert_mapping_to_xml(uploader, data, mapping, fail_required=True)
|
||||
|
||||
valid_upload_types = ['expiring-elements',
|
||||
'build-log',
|
||||
'classic']
|
||||
|
||||
types = []
|
||||
|
||||
upload_element = XML.SubElement(uploader, 'uploads')
|
||||
|
@ -8,8 +8,8 @@
|
||||
<bucketNameWithVars>gs://myBucket</bucketNameWithVars>
|
||||
<sharedPublicly>false</sharedPublicly>
|
||||
<forFailedJobs>false</forFailedJobs>
|
||||
<module/>
|
||||
<bucketObjectTTL>7</bucketObjectTTL>
|
||||
<module/>
|
||||
</com.google.jenkins.plugins.storage.ExpiringBucketLifecycleManager>
|
||||
</uploads>
|
||||
</com.google.jenkins.plugins.storage.GoogleCloudStorageUploader>
|
||||
|
@ -8,8 +8,8 @@
|
||||
<bucketNameWithVars>gs://myBucket</bucketNameWithVars>
|
||||
<sharedPublicly>false</sharedPublicly>
|
||||
<forFailedJobs>false</forFailedJobs>
|
||||
<module/>
|
||||
<bucketObjectTTL>7</bucketObjectTTL>
|
||||
<module/>
|
||||
</com.google.jenkins.plugins.storage.ExpiringBucketLifecycleManager>
|
||||
<com.google.jenkins.plugins.storage.StdoutUpload>
|
||||
<bucketNameWithVars>gs://myBucket</bucketNameWithVars>
|
||||
@ -17,8 +17,8 @@
|
||||
<forFailedJobs>true</forFailedJobs>
|
||||
<showInline>true</showInline>
|
||||
<pathPrefix/>
|
||||
<module/>
|
||||
<logName>console.log</logName>
|
||||
<module/>
|
||||
</com.google.jenkins.plugins.storage.StdoutUpload>
|
||||
<com.google.jenkins.plugins.storage.ClassicUpload>
|
||||
<bucketNameWithVars>gs://myBucket</bucketNameWithVars>
|
||||
@ -26,8 +26,8 @@
|
||||
<forFailedJobs>true</forFailedJobs>
|
||||
<showInline>false</showInline>
|
||||
<pathPrefix/>
|
||||
<module/>
|
||||
<sourceGlobWithVars>target/*.war</sourceGlobWithVars>
|
||||
<module/>
|
||||
</com.google.jenkins.plugins.storage.ClassicUpload>
|
||||
<com.google.jenkins.plugins.storage.ClassicUpload>
|
||||
<bucketNameWithVars>gs://myBucket/artifacts/</bucketNameWithVars>
|
||||
@ -35,8 +35,8 @@
|
||||
<forFailedJobs>false</forFailedJobs>
|
||||
<showInline>false</showInline>
|
||||
<pathPrefix>path/to/</pathPrefix>
|
||||
<module reference="../../com.google.jenkins.plugins.storage.ClassicUpload/module"/>
|
||||
<sourceGlobWithVars>**/build/*.iso</sourceGlobWithVars>
|
||||
<module reference="../../com.google.jenkins.plugins.storage.ClassicUpload/module"/>
|
||||
</com.google.jenkins.plugins.storage.ClassicUpload>
|
||||
</uploads>
|
||||
</com.google.jenkins.plugins.storage.GoogleCloudStorageUploader>
|
||||
|
@ -8,8 +8,8 @@
|
||||
<bucketNameWithVars>gs://myBucket</bucketNameWithVars>
|
||||
<sharedPublicly>false</sharedPublicly>
|
||||
<forFailedJobs>false</forFailedJobs>
|
||||
<module/>
|
||||
<bucketObjectTTL>7</bucketObjectTTL>
|
||||
<module/>
|
||||
</com.google.jenkins.plugins.storage.ExpiringBucketLifecycleManager>
|
||||
<com.google.jenkins.plugins.storage.StdoutUpload>
|
||||
<bucketNameWithVars>gs://myBucket</bucketNameWithVars>
|
||||
@ -17,8 +17,8 @@
|
||||
<forFailedJobs>true</forFailedJobs>
|
||||
<showInline>false</showInline>
|
||||
<pathPrefix>path/to/</pathPrefix>
|
||||
<module/>
|
||||
<logName>console.log</logName>
|
||||
<module/>
|
||||
</com.google.jenkins.plugins.storage.StdoutUpload>
|
||||
<com.google.jenkins.plugins.storage.ClassicUpload>
|
||||
<bucketNameWithVars>gs://myBucket</bucketNameWithVars>
|
||||
@ -26,15 +26,15 @@
|
||||
<forFailedJobs>false</forFailedJobs>
|
||||
<showInline>false</showInline>
|
||||
<pathPrefix>path/to/</pathPrefix>
|
||||
<module/>
|
||||
<sourceGlobWithVars>target/*.war</sourceGlobWithVars>
|
||||
<module/>
|
||||
</com.google.jenkins.plugins.storage.ClassicUpload>
|
||||
<com.google.jenkins.plugins.storage.ExpiringBucketLifecycleManager>
|
||||
<bucketNameWithVars>gs://myBucket/artifacts/</bucketNameWithVars>
|
||||
<sharedPublicly>false</sharedPublicly>
|
||||
<forFailedJobs>false</forFailedJobs>
|
||||
<module reference="../../com.google.jenkins.plugins.storage.ExpiringBucketLifecycleManager/module"/>
|
||||
<bucketObjectTTL>7</bucketObjectTTL>
|
||||
<module reference="../../com.google.jenkins.plugins.storage.ExpiringBucketLifecycleManager/module"/>
|
||||
</com.google.jenkins.plugins.storage.ExpiringBucketLifecycleManager>
|
||||
<com.google.jenkins.plugins.storage.StdoutUpload>
|
||||
<bucketNameWithVars>gs://myBucket/artifacts/</bucketNameWithVars>
|
||||
@ -42,8 +42,8 @@
|
||||
<forFailedJobs>false</forFailedJobs>
|
||||
<showInline>true</showInline>
|
||||
<pathPrefix>path/to/</pathPrefix>
|
||||
<module reference="../../com.google.jenkins.plugins.storage.StdoutUpload/module"/>
|
||||
<logName>console.log</logName>
|
||||
<module reference="../../com.google.jenkins.plugins.storage.StdoutUpload/module"/>
|
||||
</com.google.jenkins.plugins.storage.StdoutUpload>
|
||||
<com.google.jenkins.plugins.storage.ClassicUpload>
|
||||
<bucketNameWithVars>gs://myBucket/artifacts/</bucketNameWithVars>
|
||||
@ -51,8 +51,8 @@
|
||||
<forFailedJobs>true</forFailedJobs>
|
||||
<showInline>true</showInline>
|
||||
<pathPrefix>path/to/</pathPrefix>
|
||||
<module reference="../../com.google.jenkins.plugins.storage.ClassicUpload/module"/>
|
||||
<sourceGlobWithVars>target/*.war</sourceGlobWithVars>
|
||||
<module reference="../../com.google.jenkins.plugins.storage.ClassicUpload/module"/>
|
||||
</com.google.jenkins.plugins.storage.ClassicUpload>
|
||||
</uploads>
|
||||
</com.google.jenkins.plugins.storage.GoogleCloudStorageUploader>
|
||||
|
Loading…
x
Reference in New Issue
Block a user