Browse Source

Merge "artifactory-generic: Utilize convert_mapping_to_xml"

tags/2.5.0
Zuul 10 months ago
parent
commit
c32bb73d70
2 changed files with 24 additions and 21 deletions
  1. 23
    20
      jenkins_jobs/modules/wrappers.py
  2. 1
    1
      tests/wrappers/fixtures/artifactory004.xml

+ 23
- 20
jenkins_jobs/modules/wrappers.py View File

@@ -2341,18 +2341,22 @@ def artifactory_generic(registry, xml_parent, data):
2341 2341
         info.get('version', str(sys.maxsize)))
2342 2342
 
2343 2343
     if version >= pkg_resources.parse_version('2.3.0'):
2344
-        deployReleaseRepo = XML.SubElement(details, 'deployReleaseRepository')
2345
-        XML.SubElement(deployReleaseRepo, 'keyFromText').text = data.get(
2346
-            'key-from-text', '')
2347
-        XML.SubElement(deployReleaseRepo, 'keyFromSelect').text = data.get(
2348
-            'key-from-select', '')
2349
-        XML.SubElement(deployReleaseRepo, 'dynamicMode').text = str(
2350
-            'key-from-text' in data.keys()).lower()
2344
+        deploy_release_repo = XML.SubElement(
2345
+            details, 'deployReleaseRepository')
2346
+        mapping = [
2347
+            ('key-from-text', 'keyFromText', ''),
2348
+            ('key-from-select', 'keyFromSelect', ''),
2349
+            ('key-from-text', 'dynamicMode', ''),
2350
+        ]
2351
+        helpers.convert_mapping_to_xml(
2352
+            deploy_release_repo, data, mapping, fail_required=False)
2351 2353
     else:
2352
-        XML.SubElement(details, 'repositoryKey').text = data.get(
2353
-            'repo-key', '')
2354
-        XML.SubElement(details, 'snapshotsRepositoryKey').text = data.get(
2355
-            'snapshot-repo-key', '')
2354
+        mapping = [
2355
+            ('repo-key', 'repositoryKey', ''),
2356
+            ('snapshot-repo-key', 'snapshotsRepositoryKey', ''),
2357
+        ]
2358
+        helpers.convert_mapping_to_xml(
2359
+            details, data, mapping, fail_required=False)
2356 2360
 
2357 2361
     XML.SubElement(artifactory, 'deployPattern').text = ','.join(data.get(
2358 2362
         'deploy-pattern', []))
@@ -2360,15 +2364,14 @@ def artifactory_generic(registry, xml_parent, data):
2360 2364
         data.get('resolve-pattern', []))
2361 2365
     XML.SubElement(artifactory, 'matrixParams').text = ','.join(
2362 2366
         data.get('matrix-params', []))
2363
-
2364
-    XML.SubElement(artifactory, 'deployBuildInfo').text = str(
2365
-        data.get('deploy-build-info', False)).lower()
2366
-    XML.SubElement(artifactory, 'includeEnvVars').text = str(
2367
-        data.get('env-vars-include', False)).lower()
2368
-    XML.SubElement(artifactory, 'discardOldBuilds').text = str(
2369
-        data.get('discard-old-builds', False)).lower()
2370
-    XML.SubElement(artifactory, 'discardBuildArtifacts').text = str(
2371
-        data.get('discard-build-artifacts', True)).lower()
2367
+    mapping = [
2368
+        ('deploy-build-info', 'deployBuildInfo', False),
2369
+        ('env-vars-include', 'includeEnvVars', False),
2370
+        ('discard-old-builds', 'discardOldBuilds', False),
2371
+        ('discard-build-artifacts', 'discardBuildArtifacts', True),
2372
+    ]
2373
+    helpers.convert_mapping_to_xml(
2374
+        artifactory, data, mapping, fail_required=False)
2372 2375
 
2373 2376
     # envVarsPatterns
2374 2377
     helpers.artifactory_env_vars_patterns(artifactory, data)

+ 1
- 1
tests/wrappers/fixtures/artifactory004.xml View File

@@ -8,7 +8,7 @@
8 8
         <deployReleaseRepository>
9 9
           <keyFromText/>
10 10
           <keyFromSelect>repo</keyFromSelect>
11
-          <dynamicMode>false</dynamicMode>
11
+          <dynamicMode/>
12 12
         </deployReleaseRepository>
13 13
       </details>
14 14
       <deployPattern>*.zip=&gt;results</deployPattern>

Loading…
Cancel
Save