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