summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortanhengyeow <E0032242@u.nus.edu>2018-07-11 23:12:43 +0800
committertanhengyeow <E0032242@u.nus.edu>2018-07-11 23:12:43 +0800
commitf9b5016ab7fd3e0b86185a8457dff91c7a4e8361 (patch)
tree505a648327340c32f8494b882af8aadc1d4c6c51
parentabb24a18a84bc6faf1dc3a711dc832f1144310fa (diff)
Refactor builders.py
The refactoring process includes the following 1. Converted all relevant functions to use helpers.<insert function> instead of a specific import. 2. Standardized indentation for mapping tuple 3. Add commas to last entries of mapping tuples Change-Id: Ied80c8354b9d59639eba1a3bb9794f19d15c6ba3
Notes
Notes (review): Code-Review+2: Thanh Ha <zxiiro@gmail.com> Code-Review+2: Kien Ha <kienha9922@gmail.com> Workflow+1: Kien Ha <kienha9922@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 11 Jul 2018 21:40:54 +0000 Reviewed-on: https://review.openstack.org/581776 Project: openstack-infra/jenkins-job-builder Branch: refs/heads/master
-rw-r--r--jenkins_jobs/modules/builders.py477
1 files changed, 289 insertions, 188 deletions
diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py
index f0c37af..959345d 100644
--- a/jenkins_jobs/modules/builders.py
+++ b/jenkins_jobs/modules/builders.py
@@ -48,15 +48,7 @@ from jenkins_jobs.errors import JenkinsJobsException
48from jenkins_jobs.errors import MissingAttributeError 48from jenkins_jobs.errors import MissingAttributeError
49import jenkins_jobs.modules.base 49import jenkins_jobs.modules.base
50import jenkins_jobs.modules.helpers as helpers 50import jenkins_jobs.modules.helpers as helpers
51from jenkins_jobs.modules.helpers import append_git_revision_config
52import pkg_resources 51import pkg_resources
53from jenkins_jobs.modules.helpers import cloudformation_init
54from jenkins_jobs.modules.helpers import cloudformation_region_dict
55from jenkins_jobs.modules.helpers import cloudformation_stack
56from jenkins_jobs.modules.helpers import config_file_provider_builder
57from jenkins_jobs.modules.helpers import config_file_provider_settings
58from jenkins_jobs.modules.helpers import convert_mapping_to_xml
59from jenkins_jobs.modules.helpers import copyartifact_build_selector
60from jenkins_jobs.modules import hudson_model 52from jenkins_jobs.modules import hudson_model
61from jenkins_jobs.modules.publishers import ssh 53from jenkins_jobs.modules.publishers import ssh
62 54
@@ -94,9 +86,9 @@ def shell(registry, xml_parent, data):
94 mappings = [ 86 mappings = [
95 ('command', 'command', None), 87 ('command', 'command', None),
96 ('unstable-return', 'unstableReturn', 0), 88 ('unstable-return', 'unstableReturn', 0),
97
98 ] 89 ]
99 convert_mapping_to_xml(shell, data, mappings, fail_required=True) 90 helpers.convert_mapping_to_xml(
91 shell, data, mappings, fail_required=True)
100 92
101 93
102def python(registry, xml_parent, data): 94def python(registry, xml_parent, data):
@@ -198,10 +190,10 @@ def copyartifact(registry, xml_parent, data):
198 ('flatten', 'flatten', False), 190 ('flatten', 'flatten', False),
199 ('optional', 'optional', False), 191 ('optional', 'optional', False),
200 ('do-not-fingerprint', 'doNotFingerprintArtifacts', False), 192 ('do-not-fingerprint', 'doNotFingerprintArtifacts', False),
201 ('parameter-filters', 'parameters', '') 193 ('parameter-filters', 'parameters', ''),
202 ] 194 ]
203 convert_mapping_to_xml(t, data, mappings, fail_required=True) 195 helpers.convert_mapping_to_xml(t, data, mappings, fail_required=True)
204 copyartifact_build_selector(t, data) 196 helpers.copyartifact_build_selector(t, data)
205 197
206 198
207def change_assembly_version(registry, xml_parent, data): 199def change_assembly_version(registry, xml_parent, data):
@@ -233,7 +225,7 @@ def change_assembly_version(registry, xml_parent, data):
233 ('version', 'task', '1.0.0'), 225 ('version', 'task', '1.0.0'),
234 ('assembly-file', 'assemblyFile', 'AssemblyInfo.cs'), 226 ('assembly-file', 'assemblyFile', 'AssemblyInfo.cs'),
235 ] 227 ]
236 convert_mapping_to_xml(cav, data, mappings, fail_required=True) 228 helpers.convert_mapping_to_xml(cav, data, mappings, fail_required=True)
237 229
238 230
239def fingerprint(registry, xml_parent, data): 231def fingerprint(registry, xml_parent, data):
@@ -261,8 +253,11 @@ def fingerprint(registry, xml_parent, data):
261 xml_parent, 'hudson.plugins.createfingerprint.CreateFingerprint') 253 xml_parent, 'hudson.plugins.createfingerprint.CreateFingerprint')
262 fingerprint.set('plugin', 'create-fingerprint') 254 fingerprint.set('plugin', 'create-fingerprint')
263 255
264 mapping = [('targets', 'targets', '')] 256 mapping = [
265 convert_mapping_to_xml(fingerprint, data, mapping, fail_required=True) 257 ('targets', 'targets', ''),
258 ]
259 helpers.convert_mapping_to_xml(
260 fingerprint, data, mapping, fail_required=True)
266 261
267 262
268def ant(registry, xml_parent, data): 263def ant(registry, xml_parent, data):
@@ -327,7 +322,7 @@ def ant(registry, xml_parent, data):
327 322
328 mappings.append(('ant-name', 'antName', 'default')) 323 mappings.append(('ant-name', 'antName', 'default'))
329 324
330 convert_mapping_to_xml(ant, data, mappings, fail_required=True) 325 helpers.convert_mapping_to_xml(ant, data, mappings, fail_required=True)
331 326
332 327
333def trigger_remote(registry, xml_parent, data): 328def trigger_remote(registry, xml_parent, data):
@@ -386,7 +381,8 @@ def trigger_remote(registry, xml_parent, data):
386 ('prevent-remote-build-queue', 'preventRemoteBuildQueue', False), 381 ('prevent-remote-build-queue', 'preventRemoteBuildQueue', False),
387 ('block', 'blockBuildUntilComplete', True), 382 ('block', 'blockBuildUntilComplete', True),
388 ] 383 ]
389 convert_mapping_to_xml(triggerr, data, mappings, fail_required=True) 384 helpers.convert_mapping_to_xml(
385 triggerr, data, mappings, fail_required=True)
390 386
391 mappings = [] 387 mappings = []
392 if 'predefined-parameters' in data: 388 if 'predefined-parameters' in data:
@@ -409,7 +405,8 @@ def trigger_remote(registry, xml_parent, data):
409 405
410 mappings.append(('', 'overrideAuth', 'false')) 406 mappings.append(('', 'overrideAuth', 'false'))
411 407
412 convert_mapping_to_xml(triggerr, data, mappings, fail_required=True) 408 helpers.convert_mapping_to_xml(
409 triggerr, data, mappings, fail_required=True)
413 410
414 411
415def trigger_builds(registry, xml_parent, data): 412def trigger_builds(registry, xml_parent, data):
@@ -555,7 +552,8 @@ def trigger_builds(registry, xml_parent, data):
555 'SubversionRevisionBuildParameters') 552 'SubversionRevisionBuildParameters')
556 553
557 if(project_def.get('git-revision')): 554 if(project_def.get('git-revision')):
558 append_git_revision_config(tconfigs, project_def['git-revision']) 555 helpers.append_git_revision_config(
556 tconfigs, project_def['git-revision'])
559 557
560 if(project_def.get('same-node')): 558 if(project_def.get('same-node')):
561 XML.SubElement(tconfigs, 559 XML.SubElement(tconfigs,
@@ -568,16 +566,19 @@ def trigger_builds(registry, xml_parent, data):
568 mapping = [ 566 mapping = [
569 ('property-file', 'propertiesFile', None), 567 ('property-file', 'propertiesFile', None),
570 ('property-file-fail-on-missing', 568 ('property-file-fail-on-missing',
571 'failTriggerOnMissing', True)] 569 'failTriggerOnMissing', True),
572 convert_mapping_to_xml(params, 570 ]
571 helpers.convert_mapping_to_xml(params,
573 project_def, mapping, fail_required=True) 572 project_def, mapping, fail_required=True)
574 573
575 if 'predefined-parameters' in project_def: 574 if 'predefined-parameters' in project_def:
576 params = XML.SubElement(tconfigs, 575 params = XML.SubElement(tconfigs,
577 'hudson.plugins.parameterizedtrigger.' 576 'hudson.plugins.parameterizedtrigger.'
578 'PredefinedBuildParameters') 577 'PredefinedBuildParameters')
579 mapping = [('predefined-parameters', 'properties', None)] 578 mapping = [
580 convert_mapping_to_xml(params, 579 ('predefined-parameters', 'properties', None),
580 ]
581 helpers.convert_mapping_to_xml(params,
581 project_def, mapping, fail_required=True) 582 project_def, mapping, fail_required=True)
582 583
583 if 'bool-parameters' in project_def: 584 if 'bool-parameters' in project_def:
@@ -591,8 +592,9 @@ def trigger_builds(registry, xml_parent, data):
591 'BooleanParameterConfig') 592 'BooleanParameterConfig')
592 mapping = [ 593 mapping = [
593 ('name', 'name', None), 594 ('name', 'name', None),
594 ('value', 'value', False)] 595 ('value', 'value', False),
595 convert_mapping_to_xml(param, 596 ]
597 helpers.convert_mapping_to_xml(param,
596 bool_param, mapping, fail_required=True) 598 bool_param, mapping, fail_required=True)
597 599
598 if 'node-label-name' in project_def and 'node-label' in project_def: 600 if 'node-label-name' in project_def and 'node-label' in project_def:
@@ -601,16 +603,19 @@ def trigger_builds(registry, xml_parent, data):
601 'NodeLabelBuildParameter') 603 'NodeLabelBuildParameter')
602 mapping = [ 604 mapping = [
603 ('node-label-name', 'name', None), 605 ('node-label-name', 'name', None),
604 ('node-label', 'nodeLabel', None)] 606 ('node-label', 'nodeLabel', None),
605 convert_mapping_to_xml(node, 607 ]
608 helpers.convert_mapping_to_xml(node,
606 project_def, mapping, fail_required=True) 609 project_def, mapping, fail_required=True)
607 610
608 if 'restrict-matrix-project' in project_def: 611 if 'restrict-matrix-project' in project_def:
609 params = XML.SubElement(tconfigs, 612 params = XML.SubElement(tconfigs,
610 'hudson.plugins.parameterizedtrigger.' 613 'hudson.plugins.parameterizedtrigger.'
611 'matrix.MatrixSubsetBuildParameters') 614 'matrix.MatrixSubsetBuildParameters')
612 mapping = [('restrict-matrix-project', 'filter', None)] 615 mapping = [
613 convert_mapping_to_xml(params, 616 ('restrict-matrix-project', 'filter', None),
617 ]
618 helpers.convert_mapping_to_xml(params,
614 project_def, mapping, fail_required=True) 619 project_def, mapping, fail_required=True)
615 620
616 if(len(list(tconfigs)) == 0): 621 if(len(list(tconfigs)) == 0):
@@ -642,8 +647,10 @@ def trigger_builds(registry, xml_parent, data):
642 fconfigs, 647 fconfigs,
643 'hudson.plugins.parameterizedtrigger.' 648 'hudson.plugins.parameterizedtrigger.'
644 'BinaryFileParameterFactory') 649 'BinaryFileParameterFactory')
645 mapping = [('parameter-name', 'parameterName', None)] 650 mapping = [
646 convert_mapping_to_xml(params, 651 ('parameter-name', 'parameterName', None),
652 ]
653 helpers.convert_mapping_to_xml(params,
647 factory, mapping, fail_required=True) 654 factory, mapping, fail_required=True)
648 655
649 if (factory['factory'] == 'filebuild' or 656 if (factory['factory'] == 'filebuild' or
@@ -651,8 +658,9 @@ def trigger_builds(registry, xml_parent, data):
651 mapping = [ 658 mapping = [
652 ('file-pattern', 'filePattern', None), 659 ('file-pattern', 'filePattern', None),
653 ('no-files-found-action', 660 ('no-files-found-action',
654 'noFilesFoundAction', 'SKIP', supported_actions)] 661 'noFilesFoundAction', 'SKIP', supported_actions),
655 convert_mapping_to_xml(params, 662 ]
663 helpers.convert_mapping_to_xml(params,
656 factory, mapping, fail_required=True) 664 factory, mapping, fail_required=True)
657 665
658 if factory['factory'] == 'counterbuild': 666 if factory['factory'] == 'counterbuild':
@@ -660,14 +668,16 @@ def trigger_builds(registry, xml_parent, data):
660 fconfigs, 668 fconfigs,
661 'hudson.plugins.parameterizedtrigger.' 669 'hudson.plugins.parameterizedtrigger.'
662 'CounterBuildParameterFactory') 670 'CounterBuildParameterFactory')
663 mapping = [('from', 'from', None), 671 mapping = [
664 ('to', 'to', None), 672 ('from', 'from', None),
665 ('step', 'step', None), 673 ('to', 'to', None),
666 ('parameters', 'paramExpr', ''), 674 ('step', 'step', None),
667 ('validation-fail', 675 ('parameters', 'paramExpr', ''),
668 'validationFail', 676 ('validation-fail',
669 'FAIL', supported_actions)] 677 'validationFail',
670 convert_mapping_to_xml(params, 678 'FAIL', supported_actions),
679 ]
680 helpers.convert_mapping_to_xml(params,
671 factory, mapping, fail_required=True) 681 factory, mapping, fail_required=True)
672 682
673 if factory['factory'] == 'allnodesforlabel': 683 if factory['factory'] == 'allnodesforlabel':
@@ -676,11 +686,13 @@ def trigger_builds(registry, xml_parent, data):
676 'org.jvnet.jenkins.plugins.nodelabelparameter.' 686 'org.jvnet.jenkins.plugins.nodelabelparameter.'
677 'parameterizedtrigger.' 687 'parameterizedtrigger.'
678 'AllNodesForLabelBuildParameterFactory') 688 'AllNodesForLabelBuildParameterFactory')
679 mapping = [('name', 'name', ''), 689 mapping = [
680 ('node-label', 'nodeLabel', None), 690 ('name', 'name', ''),
681 ('ignore-offline-nodes', 691 ('node-label', 'nodeLabel', None),
682 'ignoreOfflineNodes', True)] 692 ('ignore-offline-nodes',
683 convert_mapping_to_xml(params, 693 'ignoreOfflineNodes', True),
694 ]
695 helpers.convert_mapping_to_xml(params,
684 factory, mapping, fail_required=True) 696 factory, mapping, fail_required=True)
685 697
686 if factory['factory'] == 'allonlinenodes': 698 if factory['factory'] == 'allonlinenodes':
@@ -696,10 +708,13 @@ def trigger_builds(registry, xml_parent, data):
696 else: 708 else:
697 projects.text = project_def['project'] 709 projects.text = project_def['project']
698 710
699 mapping = [('', 'condition', 'ALWAYS'), 711 mapping = [
700 ('', 'triggerWithNoParameters', False), 712 ('', 'condition', 'ALWAYS'),
701 ('', 'buildAllNodesWithLabel', False)] 713 ('', 'triggerWithNoParameters', False),
702 convert_mapping_to_xml(tconfig, {}, mapping, fail_required=True) 714 ('', 'buildAllNodesWithLabel', False),
715 ]
716 helpers.convert_mapping_to_xml(
717 tconfig, {}, mapping, fail_required=True)
703 718
704 block = project_def.get('block', False) 719 block = project_def.get('block', False)
705 if block: 720 if block:
@@ -728,12 +743,14 @@ def trigger_builds(registry, xml_parent, data):
728 tvalue, 743 tvalue,
729 supported_threshold_values) 744 supported_threshold_values)
730 th = XML.SubElement(block, txmltag) 745 th = XML.SubElement(block, txmltag)
731 mapping = [('name', 'name', None), 746 mapping = [
732 ('ordinal', 'ordinal', None), 747 ('name', 'name', None),
733 ('color', 'color', None), 748 ('ordinal', 'ordinal', None),
734 ('', 'completeBuild', True)] 749 ('color', 'color', None),
735 convert_mapping_to_xml(th, 750 ('', 'completeBuild', True),
736 hudson_model.THRESHOLDS[tvalue.upper()], 751 ]
752 helpers.convert_mapping_to_xml(th,
753 hudson_model.THRESHOLDS[tvalue.upper()],
737 mapping, fail_required=True) 754 mapping, fail_required=True)
738 755
739 # If configs is empty, remove the entire tbuilder tree. 756 # If configs is empty, remove the entire tbuilder tree.
@@ -757,8 +774,10 @@ def builders_from(registry, xml_parent, data):
757 """ 774 """
758 pbs = XML.SubElement(xml_parent, 775 pbs = XML.SubElement(xml_parent,
759 'hudson.plugins.templateproject.ProxyBuilder') 776 'hudson.plugins.templateproject.ProxyBuilder')
760 mapping = [('', 'projectName', data)] 777 mapping = [
761 convert_mapping_to_xml(pbs, {}, mapping, fail_required=True) 778 ('', 'projectName', data),
779 ]
780 helpers.convert_mapping_to_xml(pbs, {}, mapping, fail_required=True)
762 781
763 782
764def http_request(registry, xml_parent, data): 783def http_request(registry, xml_parent, data):
@@ -843,8 +862,10 @@ def http_request(registry, xml_parent, data):
843 ('pass-build', 'passBuildParameters', False), 862 ('pass-build', 'passBuildParameters', False),
844 ('time-out', 'timeout', 0), 863 ('time-out', 'timeout', 0),
845 ('valid-response-codes', 'validResponseCodes', ''), 864 ('valid-response-codes', 'validResponseCodes', ''),
846 ('valid-response-content', 'validResponseContent', '')] 865 ('valid-response-content', 'validResponseContent', ''),
847 convert_mapping_to_xml(http_request, data, mappings, fail_required=True) 866 ]
867 helpers.convert_mapping_to_xml(
868 http_request, data, mappings, fail_required=True)
848 869
849 if 'authentication-key' in data: 870 if 'authentication-key' in data:
850 XML.SubElement( 871 XML.SubElement(
@@ -854,11 +875,11 @@ def http_request(registry, xml_parent, data):
854 customHeader = XML.SubElement(http_request, 'customHeaders') 875 customHeader = XML.SubElement(http_request, 'customHeaders')
855 header_mappings = [ 876 header_mappings = [
856 ('name', 'name', None), 877 ('name', 'name', None),
857 ('value', 'value', None) 878 ('value', 'value', None),
858 ] 879 ]
859 for customhead in data['custom-headers']: 880 for customhead in data['custom-headers']:
860 pair = XML.SubElement(customHeader, 'pair') 881 pair = XML.SubElement(customHeader, 'pair')
861 convert_mapping_to_xml(pair, 882 helpers.convert_mapping_to_xml(pair,
862 customhead, 883 customhead,
863 header_mappings, 884 header_mappings,
864 fail_required=True) 885 fail_required=True)
@@ -888,7 +909,7 @@ def inject(registry, xml_parent, data):
888 ('script-file', 'scriptFilePath', None), 909 ('script-file', 'scriptFilePath', None),
889 ('script-content', 'scriptContent', None), 910 ('script-content', 'scriptContent', None),
890 ] 911 ]
891 convert_mapping_to_xml(info, data, mapping, fail_required=False) 912 helpers.convert_mapping_to_xml(info, data, mapping, fail_required=False)
892 913
893 914
894def kmap(registry, xml_parent, data): 915def kmap(registry, xml_parent, data):
@@ -951,7 +972,7 @@ def kmap(registry, xml_parent, data):
951 ('description', 'description', ''), 972 ('description', 'description', ''),
952 ('icon-path', 'iconPath', ''), 973 ('icon-path', 'iconPath', ''),
953 ] 974 ]
954 convert_mapping_to_xml(kmap, data, mapping, fail_required=True) 975 helpers.convert_mapping_to_xml(kmap, data, mapping, fail_required=True)
955 976
956 if publish is True: 977 if publish is True:
957 publish_optional = XML.SubElement(kmap, 'publishOptional') 978 publish_optional = XML.SubElement(kmap, 'publishOptional')
@@ -960,7 +981,7 @@ def kmap(registry, xml_parent, data):
960 ('users', 'users', ''), 981 ('users', 'users', ''),
961 ('notify-users', 'sendNotifications', False), 982 ('notify-users', 'sendNotifications', False),
962 ] 983 ]
963 convert_mapping_to_xml( 984 helpers.convert_mapping_to_xml(
964 publish_optional, data, publish_mapping, fail_required=True) 985 publish_optional, data, publish_mapping, fail_required=True)
965 986
966 987
@@ -1010,7 +1031,7 @@ def artifact_resolver(registry, xml_parent, data):
1010 ('', 'snapshotChecksumPolicy', 'warn'), 1031 ('', 'snapshotChecksumPolicy', 'warn'),
1011 ('', 'releaseChecksumPolicy', 'warn'), 1032 ('', 'releaseChecksumPolicy', 'warn'),
1012 ] 1033 ]
1013 convert_mapping_to_xml(ar, data, mapping, fail_required=True) 1034 helpers.convert_mapping_to_xml(ar, data, mapping, fail_required=True)
1014 1035
1015 artifact_top = XML.SubElement(ar, 'artifacts') 1036 artifact_top = XML.SubElement(ar, 'artifacts')
1016 artifacts = data['artifacts'] 1037 artifacts = data['artifacts']
@@ -1026,7 +1047,7 @@ def artifact_resolver(registry, xml_parent, data):
1026 rcartifact = XML.SubElement( 1047 rcartifact = XML.SubElement(
1027 artifact_top, 1048 artifact_top,
1028 'org.jvnet.hudson.plugins.repositoryconnector.Artifact') 1049 'org.jvnet.hudson.plugins.repositoryconnector.Artifact')
1029 convert_mapping_to_xml( 1050 helpers.convert_mapping_to_xml(
1030 rcartifact, artifact, artifacts_mapping, fail_required=True) 1051 rcartifact, artifact, artifacts_mapping, fail_required=True)
1031 1052
1032 1053
@@ -1054,9 +1075,9 @@ def doxygen(registry, xml_parent, data):
1054 ('doxyfile', 'doxyfilePath', None), 1075 ('doxyfile', 'doxyfilePath', None),
1055 ('install', 'installationName', None), 1076 ('install', 'installationName', None),
1056 ('ignore-failure', 'continueOnBuildFailure', False), 1077 ('ignore-failure', 'continueOnBuildFailure', False),
1057 ('unstable-warning', 'unstableIfWarnings', False) 1078 ('unstable-warning', 'unstableIfWarnings', False),
1058 ] 1079 ]
1059 convert_mapping_to_xml(doxygen, data, mappings, fail_required=True) 1080 helpers.convert_mapping_to_xml(doxygen, data, mappings, fail_required=True)
1060 1081
1061 1082
1062def gradle(registry, xml_parent, data): 1083def gradle(registry, xml_parent, data):
@@ -1096,7 +1117,7 @@ def gradle(registry, xml_parent, data):
1096 ('executable', 'makeExecutable', False), 1117 ('executable', 'makeExecutable', False),
1097 ('use-root-dir', 'fromRootBuildScriptDir', False), 1118 ('use-root-dir', 'fromRootBuildScriptDir', False),
1098 ] 1119 ]
1099 convert_mapping_to_xml(gradle, data, mappings, fail_required=True) 1120 helpers.convert_mapping_to_xml(gradle, data, mappings, fail_required=True)
1100 1121
1101 XML.SubElement(gradle, 'switches').text = '\n'.join( 1122 XML.SubElement(gradle, 'switches').text = '\n'.join(
1102 data.get('switches', [])) 1123 data.get('switches', []))
@@ -1111,12 +1132,18 @@ def _groovy_common_scriptSource(data):
1111 raise JenkinsJobsException("Use just one of 'command' or 'file'") 1132 raise JenkinsJobsException("Use just one of 'command' or 'file'")
1112 1133
1113 if 'command' in data: 1134 if 'command' in data:
1114 mapping = [('command', 'command', None)] 1135 mapping = [
1115 convert_mapping_to_xml(scriptSource, data, mapping, fail_required=True) 1136 ('command', 'command', None),
1137 ]
1138 helpers.convert_mapping_to_xml(
1139 scriptSource, data, mapping, fail_required=True)
1116 scriptSource.set('class', 'hudson.plugins.groovy.StringScriptSource') 1140 scriptSource.set('class', 'hudson.plugins.groovy.StringScriptSource')
1117 elif 'file' in data: 1141 elif 'file' in data:
1118 mapping = [('file', 'scriptFile', None)] 1142 mapping = [
1119 convert_mapping_to_xml(scriptSource, data, mapping, fail_required=True) 1143 ('file', 'scriptFile', None),
1144 ]
1145 helpers.convert_mapping_to_xml(
1146 scriptSource, data, mapping, fail_required=True)
1120 scriptSource.set('class', 'hudson.plugins.groovy.FileScriptSource') 1147 scriptSource.set('class', 'hudson.plugins.groovy.FileScriptSource')
1121 else: 1148 else:
1122 raise JenkinsJobsException("A groovy command or file is required") 1149 raise JenkinsJobsException("A groovy command or file is required")
@@ -1168,9 +1195,9 @@ def groovy(registry, xml_parent, data):
1168 ('script-parameters', 'scriptParameters', ''), 1195 ('script-parameters', 'scriptParameters', ''),
1169 ('properties', 'properties', ''), 1196 ('properties', 'properties', ''),
1170 ('java-opts', 'javaOpts', ''), 1197 ('java-opts', 'javaOpts', ''),
1171 ('class-path', 'classPath', '') 1198 ('class-path', 'classPath', ''),
1172 ] 1199 ]
1173 convert_mapping_to_xml(groovy, data, mappings, fail_required=True) 1200 helpers.convert_mapping_to_xml(groovy, data, mappings, fail_required=True)
1174 1201
1175 1202
1176def system_groovy(registry, xml_parent, data): 1203def system_groovy(registry, xml_parent, data):
@@ -1204,7 +1231,8 @@ def system_groovy(registry, xml_parent, data):
1204 ('bindings', 'bindings', ''), 1231 ('bindings', 'bindings', ''),
1205 ('class-path', 'classpath', ''), 1232 ('class-path', 'classpath', ''),
1206 ] 1233 ]
1207 convert_mapping_to_xml(sysgroovy, data, mapping, fail_required=True) 1234 helpers.convert_mapping_to_xml(
1235 sysgroovy, data, mapping, fail_required=True)
1208 1236
1209 1237
1210def batch(registry, xml_parent, data): 1238def batch(registry, xml_parent, data):
@@ -1274,9 +1302,10 @@ def msbuild(registry, xml_parent, data):
1274 ('extra-parameters', 'cmdLineArgs', ''), 1302 ('extra-parameters', 'cmdLineArgs', ''),
1275 ('pass-build-variables', 'buildVariablesAsProperties', True), 1303 ('pass-build-variables', 'buildVariablesAsProperties', True),
1276 ('continue-on-build-failure', 'continueOnBuildFailure', False), 1304 ('continue-on-build-failure', 'continueOnBuildFailure', False),
1277 ('unstable-if-warnings', 'unstableIfWarnings', False) 1305 ('unstable-if-warnings', 'unstableIfWarnings', False),
1278 ] 1306 ]
1279 convert_mapping_to_xml(msbuilder, data, mapping, fail_required=True) 1307 helpers.convert_mapping_to_xml(
1308 msbuilder, data, mapping, fail_required=True)
1280 1309
1281 1310
1282def create_builders(registry, step): 1311def create_builders(registry, step):
@@ -1504,8 +1533,11 @@ def conditional_step(registry, xml_parent, data):
1504 ctag.set('class', core_prefix + 'NeverRun') 1533 ctag.set('class', core_prefix + 'NeverRun')
1505 elif kind == "boolean-expression": 1534 elif kind == "boolean-expression":
1506 ctag.set('class', core_prefix + 'BooleanCondition') 1535 ctag.set('class', core_prefix + 'BooleanCondition')
1507 mapping = [('condition-expression', 'token', None)] 1536 mapping = [
1508 convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True) 1537 ('condition-expression', 'token', None),
1538 ]
1539 helpers.convert_mapping_to_xml(
1540 ctag, cdata, mapping, fail_required=True)
1509 elif kind == "build-cause": 1541 elif kind == "build-cause":
1510 ctag.set('class', core_prefix + 'CauseCondition') 1542 ctag.set('class', core_prefix + 'CauseCondition')
1511 cause_list = ('USER_CAUSE', 'SCM_CAUSE', 'TIMER_CAUSE', 1543 cause_list = ('USER_CAUSE', 'SCM_CAUSE', 'TIMER_CAUSE',
@@ -1514,8 +1546,10 @@ def conditional_step(registry, xml_parent, data):
1514 'SCRIPT_CAUSE', 'BUILDRESULT_CAUSE') 1546 'SCRIPT_CAUSE', 'BUILDRESULT_CAUSE')
1515 mapping = [ 1547 mapping = [
1516 ('cause', 'buildCause', 'USER_CAUSE', cause_list), 1548 ('cause', 'buildCause', 'USER_CAUSE', cause_list),
1517 ('exclusive-cause', "exclusiveCause", False)] 1549 ('exclusive-cause', "exclusiveCause", False),
1518 convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True) 1550 ]
1551 helpers.convert_mapping_to_xml(
1552 ctag, cdata, mapping, fail_required=True)
1519 elif kind == "day-of-week": 1553 elif kind == "day-of-week":
1520 ctag.set('class', core_prefix + 'DayCondition') 1554 ctag.set('class', core_prefix + 'DayCondition')
1521 day_selector_class_prefix = core_prefix + 'DayCondition$' 1555 day_selector_class_prefix = core_prefix + 'DayCondition$'
@@ -1542,24 +1576,31 @@ def conditional_step(registry, xml_parent, data):
1542 ('', 'day', day_no), 1576 ('', 'day', day_no),
1543 (day, "selected", False), 1577 (day, "selected", False),
1544 ] 1578 ]
1545 convert_mapping_to_xml(day_tag, 1579 helpers.convert_mapping_to_xml(day_tag,
1546 inp_days, mapping, fail_required=True) 1580 inp_days, mapping, fail_required=True)
1547 mapping = [('use-build-time', "useBuildTime", False)] 1581 mapping = [
1548 convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True) 1582 ('use-build-time', "useBuildTime", False),
1583 ]
1584 helpers.convert_mapping_to_xml(
1585 ctag, cdata, mapping, fail_required=True)
1549 elif kind == "execution-node": 1586 elif kind == "execution-node":
1550 ctag.set('class', core_prefix + 'NodeCondition') 1587 ctag.set('class', core_prefix + 'NodeCondition')
1551 allowed_nodes_tag = XML.SubElement(ctag, "allowedNodes") 1588 allowed_nodes_tag = XML.SubElement(ctag, "allowedNodes")
1552 for node in cdata['nodes']: 1589 for node in cdata['nodes']:
1553 mapping = [('', "string", node)] 1590 mapping = [
1554 convert_mapping_to_xml(allowed_nodes_tag, 1591 ('', "string", node),
1592 ]
1593 helpers.convert_mapping_to_xml(allowed_nodes_tag,
1555 cdata, mapping, fail_required=True) 1594 cdata, mapping, fail_required=True)
1556 elif kind == "strings-match": 1595 elif kind == "strings-match":
1557 ctag.set('class', core_prefix + 'StringsMatchCondition') 1596 ctag.set('class', core_prefix + 'StringsMatchCondition')
1558 mapping = [ 1597 mapping = [
1559 ('condition-string1', "arg1", ''), 1598 ('condition-string1', "arg1", ''),
1560 ('condition-string2', "arg2", ''), 1599 ('condition-string2', "arg2", ''),
1561 ('condition-case-insensitive', "ignoreCase", False)] 1600 ('condition-case-insensitive', "ignoreCase", False),
1562 convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True) 1601 ]
1602 helpers.convert_mapping_to_xml(
1603 ctag, cdata, mapping, fail_required=True)
1563 elif kind == "current-status": 1604 elif kind == "current-status":
1564 ctag.set('class', core_prefix + 'StatusCondition') 1605 ctag.set('class', core_prefix + 'StatusCondition')
1565 wr = XML.SubElement(ctag, 'worstResult') 1606 wr = XML.SubElement(ctag, 'worstResult')
@@ -1572,8 +1613,9 @@ def conditional_step(registry, xml_parent, data):
1572 ('name', 'name', None), 1613 ('name', 'name', None),
1573 ('ordinal', 'ordinal', None), 1614 ('ordinal', 'ordinal', None),
1574 ('color', 'color', 'color'), 1615 ('color', 'color', 'color'),
1575 ('complete', 'completeBuild', None)] 1616 ('complete', 'completeBuild', None),
1576 convert_mapping_to_xml(wr, 1617 ]
1618 helpers.convert_mapping_to_xml(wr,
1577 wr_threshold, mapping, fail_required=True) 1619 wr_threshold, mapping, fail_required=True)
1578 br = XML.SubElement(ctag, 'bestResult') 1620 br = XML.SubElement(ctag, 'bestResult')
1579 br_name = cdata.get('condition-best', 'SUCCESS') 1621 br_name = cdata.get('condition-best', 'SUCCESS')
@@ -1585,26 +1627,35 @@ def conditional_step(registry, xml_parent, data):
1585 ('name', 'name', None), 1627 ('name', 'name', None),
1586 ('ordinal', 'ordinal', None), 1628 ('ordinal', 'ordinal', None),
1587 ('color', 'color', 'color'), 1629 ('color', 'color', 'color'),
1588 ('complete', 'completeBuild', None)] 1630 ('complete', 'completeBuild', None),
1589 convert_mapping_to_xml(br, 1631 ]
1632 helpers.convert_mapping_to_xml(br,
1590 br_threshold, mapping, fail_required=True) 1633 br_threshold, mapping, fail_required=True)
1591 elif kind == "shell": 1634 elif kind == "shell":
1592 ctag.set('class', 1635 ctag.set('class',
1593 'org.jenkins_ci.plugins.run_condition.contributed.' 1636 'org.jenkins_ci.plugins.run_condition.contributed.'
1594 'ShellCondition') 1637 'ShellCondition')
1595 mapping = [('condition-command', 'command', '')] 1638 mapping = [
1596 convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True) 1639 ('condition-command', 'command', ''),
1640 ]
1641 helpers.convert_mapping_to_xml(
1642 ctag, cdata, mapping, fail_required=True)
1597 elif kind == "windows-shell": 1643 elif kind == "windows-shell":
1598 ctag.set('class', 1644 ctag.set('class',
1599 'org.jenkins_ci.plugins.run_condition.contributed.' 1645 'org.jenkins_ci.plugins.run_condition.contributed.'
1600 'BatchFileCondition') 1646 'BatchFileCondition')
1601 mapping = [('condition-command', 'command', '')] 1647 mapping = [
1602 convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True) 1648 ('condition-command', 'command', ''),
1649 ]
1650 helpers.convert_mapping_to_xml(
1651 ctag, cdata, mapping, fail_required=True)
1603 elif kind == "file-exists" or kind == "files-match": 1652 elif kind == "file-exists" or kind == "files-match":
1604 if kind == "file-exists": 1653 if kind == "file-exists":
1605 ctag.set('class', core_prefix + 'FileExistsCondition') 1654 ctag.set('class', core_prefix + 'FileExistsCondition')
1606 mapping = [('condition-filename', 'file', None)] 1655 mapping = [
1607 convert_mapping_to_xml(ctag, cdata, mapping, 1656 ('condition-filename', 'file', None),
1657 ]
1658 helpers.convert_mapping_to_xml(ctag, cdata, mapping,
1608 fail_required=True) 1659 fail_required=True)
1609 else: 1660 else:
1610 ctag.set('class', core_prefix + 'FilesMatchCondition') 1661 ctag.set('class', core_prefix + 'FilesMatchCondition')
@@ -1629,8 +1680,10 @@ def conditional_step(registry, xml_parent, data):
1629 ctag.set('class', core_prefix + 'NumericalComparisonCondition') 1680 ctag.set('class', core_prefix + 'NumericalComparisonCondition')
1630 mapping = [ 1681 mapping = [
1631 ('lhs', 'lhs', None), 1682 ('lhs', 'lhs', None),
1632 ('rhs', 'rhs', None)] 1683 ('rhs', 'rhs', None),
1633 convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True) 1684 ]
1685 helpers.convert_mapping_to_xml(
1686 ctag, cdata, mapping, fail_required=True)
1634 comp_class_prefix = core_prefix + 'NumericalComparisonCondition$' 1687 comp_class_prefix = core_prefix + 'NumericalComparisonCondition$'
1635 comp_classes = { 1688 comp_classes = {
1636 'less-than': comp_class_prefix + 'LessThan', 1689 'less-than': comp_class_prefix + 'LessThan',
@@ -1650,8 +1703,10 @@ def conditional_step(registry, xml_parent, data):
1650 ctag.set('class', core_prefix + 'ExpressionCondition') 1703 ctag.set('class', core_prefix + 'ExpressionCondition')
1651 mapping = [ 1704 mapping = [
1652 ('regex', 'expression', ''), 1705 ('regex', 'expression', ''),
1653 ('label', 'label', '')] 1706 ('label', 'label', ''),
1654 convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True) 1707 ]
1708 helpers.convert_mapping_to_xml(
1709 ctag, cdata, mapping, fail_required=True)
1655 elif kind == "time": 1710 elif kind == "time":
1656 ctag.set('class', core_prefix + 'TimeCondition') 1711 ctag.set('class', core_prefix + 'TimeCondition')
1657 mapping = [ 1712 mapping = [
@@ -1659,9 +1714,10 @@ def conditional_step(registry, xml_parent, data):
1659 ('earliest-min', 'earliestMinutes', '00'), 1714 ('earliest-min', 'earliestMinutes', '00'),
1660 ('latest-hour', 'latestHours', '17'), 1715 ('latest-hour', 'latestHours', '17'),
1661 ('latest-min', 'latestMinutes', '30'), 1716 ('latest-min', 'latestMinutes', '30'),
1662 ('use-build-time', 'useBuildTime', False) 1717 ('use-build-time', 'useBuildTime', False),
1663 ] 1718 ]
1664 convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True) 1719 helpers.convert_mapping_to_xml(
1720 ctag, cdata, mapping, fail_required=True)
1665 elif kind == "not": 1721 elif kind == "not":
1666 ctag.set('class', logic_prefix + 'Not') 1722 ctag.set('class', logic_prefix + 'Not')
1667 try: 1723 try:
@@ -1755,7 +1811,7 @@ def maven_builder(registry, xml_parent, data):
1755 ('pom', 'rootPom', 'pom.xml'), 1811 ('pom', 'rootPom', 'pom.xml'),
1756 ('maven-opts', 'mavenOpts', ''), 1812 ('maven-opts', 'mavenOpts', ''),
1757 ] 1813 ]
1758 convert_mapping_to_xml(maven, data, mapping, fail_required=True) 1814 helpers.convert_mapping_to_xml(maven, data, mapping, fail_required=True)
1759 1815
1760 1816
1761def jira_issue_updater(registry, xml_parent, data): 1817def jira_issue_updater(registry, xml_parent, data):
@@ -1808,9 +1864,10 @@ def jira_issue_updater(registry, xml_parent, data):
1808 ('custom-value', 'customFieldValue', ''), 1864 ('custom-value', 'customFieldValue', ''),
1809 ('fail-if-error', 'failIfJqlFails', False), 1865 ('fail-if-error', 'failIfJqlFails', False),
1810 ('fail-if-no-match', 'failIfNoIssuesReturned', False), 1866 ('fail-if-no-match', 'failIfNoIssuesReturned', False),
1811 ('fail-if-no-connection', 'failIfNoJiraConnection', False) 1867 ('fail-if-no-connection', 'failIfNoJiraConnection', False),
1812 ] 1868 ]
1813 convert_mapping_to_xml(issue_updater, data, mapping, fail_required=True) 1869 helpers.convert_mapping_to_xml(
1870 issue_updater, data, mapping, fail_required=True)
1814 1871
1815 1872
1816def maven_target(registry, xml_parent, data): 1873def maven_target(registry, xml_parent, data):
@@ -1858,12 +1915,13 @@ def maven_target(registry, xml_parent, data):
1858 mapping = [ 1915 mapping = [
1859 ('maven-version', 'mavenName', None), 1916 ('maven-version', 'mavenName', None),
1860 ('pom', 'pom', None), 1917 ('pom', 'pom', None),
1861 ('private-repository', 'usePrivateRepository', False)] 1918 ('private-repository', 'usePrivateRepository', False),
1862 convert_mapping_to_xml(maven, data, mapping, fail_required=False) 1919 ]
1920 helpers.convert_mapping_to_xml(maven, data, mapping, fail_required=False)
1863 if 'java-opts' in data: 1921 if 'java-opts' in data:
1864 javaoptions = ' '.join(data.get('java-opts', [])) 1922 javaoptions = ' '.join(data.get('java-opts', []))
1865 XML.SubElement(maven, 'jvmOptions').text = javaoptions 1923 XML.SubElement(maven, 'jvmOptions').text = javaoptions
1866 config_file_provider_settings(maven, data) 1924 helpers.config_file_provider_settings(maven, data)
1867 1925
1868 1926
1869def multijob(registry, xml_parent, data): 1927def multijob(registry, xml_parent, data):
@@ -1937,8 +1995,9 @@ def multijob(registry, xml_parent, data):
1937 ('condition', 'continuationCondition', 1995 ('condition', 'continuationCondition',
1938 'SUCCESSFUL', conditions_available), 1996 'SUCCESSFUL', conditions_available),
1939 ('execution-type', 'executionType', 1997 ('execution-type', 'executionType',
1940 'PARALLEL', job_execution_type_available)] 1998 'PARALLEL', job_execution_type_available),
1941 convert_mapping_to_xml(builder, data, mapping, fail_required=True) 1999 ]
2000 helpers.convert_mapping_to_xml(builder, data, mapping, fail_required=True)
1942 2001
1943 phaseJobs = XML.SubElement(builder, 'phaseJobs') 2002 phaseJobs = XML.SubElement(builder, 'phaseJobs')
1944 2003
@@ -1950,8 +2009,10 @@ def multijob(registry, xml_parent, data):
1950 mapping = [ 2009 mapping = [
1951 ('name', 'jobName', None), 2010 ('name', 'jobName', None),
1952 # Pass through the current build params 2011 # Pass through the current build params
1953 ('current-parameters', 'currParams', False)] 2012 ('current-parameters', 'currParams', False),
1954 convert_mapping_to_xml(phaseJob, project, mapping, fail_required=True) 2013 ]
2014 helpers.convert_mapping_to_xml(
2015 phaseJob, project, mapping, fail_required=True)
1955 # Pass through other params 2016 # Pass through other params
1956 configs = XML.SubElement(phaseJob, 'configs') 2017 configs = XML.SubElement(phaseJob, 'configs')
1957 2018
@@ -1963,8 +2024,10 @@ def multijob(registry, xml_parent, data):
1963 'parameterizedtrigger.NodeLabelBuildParameter') 2024 'parameterizedtrigger.NodeLabelBuildParameter')
1964 mapping = [ 2025 mapping = [
1965 ('', 'name', nodeLabelName), 2026 ('', 'name', nodeLabelName),
1966 ('', 'nodeLabel', nodeLabel)] 2027 ('', 'nodeLabel', nodeLabel),
1967 convert_mapping_to_xml(node, project, mapping, fail_required=True) 2028 ]
2029 helpers.convert_mapping_to_xml(
2030 node, project, mapping, fail_required=True)
1968 2031
1969 # Node parameter 2032 # Node parameter
1970 if project.get('node-parameters', False): 2033 if project.get('node-parameters', False):
@@ -1976,8 +2039,11 @@ def multijob(registry, xml_parent, data):
1976 param = XML.SubElement(configs, 2039 param = XML.SubElement(configs,
1977 'hudson.plugins.git.' 2040 'hudson.plugins.git.'
1978 'GitRevisionBuildParameters') 2041 'GitRevisionBuildParameters')
1979 mapping = [('', 'combineQueuedCommits', False)] 2042 mapping = [
1980 convert_mapping_to_xml(param, project, mapping, fail_required=True) 2043 ('', 'combineQueuedCommits', False),
2044 ]
2045 helpers.convert_mapping_to_xml(
2046 param, project, mapping, fail_required=True)
1981 2047
1982 # Properties File 2048 # Properties File
1983 properties_file = project.get('property-file', False) 2049 properties_file = project.get('property-file', False)
@@ -1987,8 +2053,10 @@ def multijob(registry, xml_parent, data):
1987 'FileBuildParameters') 2053 'FileBuildParameters')
1988 mapping = [ 2054 mapping = [
1989 ('', 'propertiesFile', properties_file), 2055 ('', 'propertiesFile', properties_file),
1990 ('', 'failTriggerOnMissing', True)] 2056 ('', 'failTriggerOnMissing', True),
1991 convert_mapping_to_xml(param, project, mapping, fail_required=True) 2057 ]
2058 helpers.convert_mapping_to_xml(
2059 param, project, mapping, fail_required=True)
1992 2060
1993 # Predefined Parameters 2061 # Predefined Parameters
1994 predefined_parameters = project.get('predefined-parameters', False) 2062 predefined_parameters = project.get('predefined-parameters', False)
@@ -1996,14 +2064,18 @@ def multijob(registry, xml_parent, data):
1996 param = XML.SubElement(configs, 2064 param = XML.SubElement(configs,
1997 'hudson.plugins.parameterizedtrigger.' 2065 'hudson.plugins.parameterizedtrigger.'
1998 'PredefinedBuildParameters') 2066 'PredefinedBuildParameters')
1999 mapping = [('', 'properties', predefined_parameters)] 2067 mapping = [
2000 convert_mapping_to_xml(param, project, mapping, fail_required=True) 2068 ('', 'properties', predefined_parameters),
2069 ]
2070 helpers.convert_mapping_to_xml(
2071 param, project, mapping, fail_required=True)
2001 2072
2002 mapping = [ 2073 mapping = [
2003 ('abort-all-job', 'abortAllJob', False), 2074 ('abort-all-job', 'abortAllJob', False),
2004 ('aggregate-results', 'aggregatedTestResults', False), 2075 ('aggregate-results', 'aggregatedTestResults', False),
2005 ] 2076 ]
2006 convert_mapping_to_xml(phaseJob, project, mapping, fail_required=True) 2077 helpers.convert_mapping_to_xml(
2078 phaseJob, project, mapping, fail_required=True)
2007 2079
2008 # Retry job 2080 # Retry job
2009 retry = project.get('retry', False) 2081 retry = project.get('retry', False)
@@ -2012,8 +2084,9 @@ def multijob(registry, xml_parent, data):
2012 mapping = [ 2084 mapping = [
2013 ('strategy-path', 'parsingRulesPath', None), 2085 ('strategy-path', 'parsingRulesPath', None),
2014 ('', 'maxRetries', int(max_retry)), 2086 ('', 'maxRetries', int(max_retry)),
2015 ('', 'enableRetryStrategy', True)] 2087 ('', 'enableRetryStrategy', True),
2016 convert_mapping_to_xml(phaseJob, 2088 ]
2089 helpers.convert_mapping_to_xml(phaseJob,
2017 retry, mapping, fail_required=True) 2090 retry, mapping, fail_required=True)
2018 else: 2091 else:
2019 XML.SubElement(phaseJob, 'enableRetryStrategy').text = 'false' 2092 XML.SubElement(phaseJob, 'enableRetryStrategy').text = 'false'
@@ -2023,8 +2096,10 @@ def multijob(registry, xml_parent, data):
2023 subset = XML.SubElement( 2096 subset = XML.SubElement(
2024 configs, 'hudson.plugins.parameterizedtrigger.' 2097 configs, 'hudson.plugins.parameterizedtrigger.'
2025 'matrix.MatrixSubsetBuildParameters') 2098 'matrix.MatrixSubsetBuildParameters')
2026 mapping = [('restrict-matrix-project', 'filter', None)] 2099 mapping = [
2027 convert_mapping_to_xml(subset, 2100 ('restrict-matrix-project', 'filter', None),
2101 ]
2102 helpers.convert_mapping_to_xml(subset,
2028 project, mapping, fail_required=True) 2103 project, mapping, fail_required=True)
2029 2104
2030 # Enable Condition 2105 # Enable Condition
@@ -2032,17 +2107,20 @@ def multijob(registry, xml_parent, data):
2032 if enable_condition is not None: 2107 if enable_condition is not None:
2033 mapping = [ 2108 mapping = [
2034 ('', 'enableCondition', True), 2109 ('', 'enableCondition', True),
2035 ('', 'condition', enable_condition)] 2110 ('', 'condition', enable_condition),
2036 convert_mapping_to_xml(phaseJob, 2111 ]
2112 helpers.convert_mapping_to_xml(phaseJob,
2037 project, mapping, fail_required=True) 2113 project, mapping, fail_required=True)
2038 2114
2039 # Kill phase on job status 2115 # Kill phase on job status
2040 kill_status = project.get('kill-phase-on') 2116 kill_status = project.get('kill-phase-on')
2041 if kill_status is not None: 2117 if kill_status is not None:
2042 kill_status = kill_status.upper() 2118 kill_status = kill_status.upper()
2043 mapping = [('', 'killPhaseOnJobResultCondition', 2119 mapping = [
2044 kill_status, kill_status_list)] 2120 ('', 'killPhaseOnJobResultCondition',
2045 convert_mapping_to_xml(phaseJob, 2121 kill_status, kill_status_list),
2122 ]
2123 helpers.convert_mapping_to_xml(phaseJob,
2046 project, mapping, fail_required=True) 2124 project, mapping, fail_required=True)
2047 2125
2048 2126
@@ -2077,7 +2155,7 @@ def config_file_provider(registry, xml_parent, data):
2077 'org.jenkinsci.plugins.configfiles.builder.' 2155 'org.jenkinsci.plugins.configfiles.builder.'
2078 'ConfigFileBuildStep') 2156 'ConfigFileBuildStep')
2079 cfp.set('plugin', 'config-file-provider') 2157 cfp.set('plugin', 'config-file-provider')
2080 config_file_provider_builder(cfp, data) 2158 helpers.config_file_provider_builder(cfp, data)
2081 2159
2082 2160
2083def grails(registry, xml_parent, data): 2161def grails(registry, xml_parent, data):
@@ -2140,7 +2218,7 @@ def grails(registry, xml_parent, data):
2140 ('verbose', 'verbose', False), 2218 ('verbose', 'verbose', False),
2141 ('refresh-dependencies', 'refreshDependencies', False), 2219 ('refresh-dependencies', 'refreshDependencies', False),
2142 ] 2220 ]
2143 convert_mapping_to_xml(grails, data, mappings, fail_required=True) 2221 helpers.convert_mapping_to_xml(grails, data, mappings, fail_required=True)
2144 2222
2145 2223
2146def sbt(registry, xml_parent, data): 2224def sbt(registry, xml_parent, data):
@@ -2172,7 +2250,7 @@ def sbt(registry, xml_parent, data):
2172 ('actions', 'actions', ''), 2250 ('actions', 'actions', ''),
2173 ('subdir-path', 'subdirPath', ''), 2251 ('subdir-path', 'subdirPath', ''),
2174 ] 2252 ]
2175 convert_mapping_to_xml(sbt, data, mappings, fail_required=True) 2253 helpers.convert_mapping_to_xml(sbt, data, mappings, fail_required=True)
2176 2254
2177 2255
2178def critical_block_start(registry, xml_parent, data): 2256def critical_block_start(registry, xml_parent, data):
@@ -2310,7 +2388,7 @@ def saltstack(parser, xml_parent, data):
2310 ('polltime', 'jobPollTime', ''), 2388 ('polltime', 'jobPollTime', ''),
2311 ('batchsize', 'batchSize', '100%'), 2389 ('batchsize', 'batchSize', '100%'),
2312 ('mods', 'mods', ''), 2390 ('mods', 'mods', ''),
2313 ('saveoutput', 'saveEnvVar', False) 2391 ('saveoutput', 'saveEnvVar', False),
2314 ] 2392 ]
2315 2393
2316 helpers.convert_mapping_to_xml(saltstack, data, mapping, 2394 helpers.convert_mapping_to_xml(saltstack, data, mapping,
@@ -2506,27 +2584,35 @@ def shining_panda(registry, xml_parent, data):
2506 2584
2507 if buildenv in ('python', 'virtualenv'): 2585 if buildenv in ('python', 'virtualenv'):
2508 python_mapping = [ 2586 python_mapping = [
2509 ('python-version', 'pythonName', 'System-CPython-2.7')] 2587 ('python-version', 'pythonName', 'System-CPython-2.7'),
2510 convert_mapping_to_xml(t, data, python_mapping, fail_required=True) 2588 ]
2589 helpers.convert_mapping_to_xml(
2590 t, data, python_mapping, fail_required=True)
2511 2591
2512 if buildenv in 'custom': 2592 if buildenv in 'custom':
2513 custom_mapping = [('home', 'home', None)] 2593 custom_mapping = [
2514 convert_mapping_to_xml(t, data, custom_mapping, fail_required=True) 2594 ('home', 'home', None),
2595 ]
2596 helpers.convert_mapping_to_xml(
2597 t, data, custom_mapping, fail_required=True)
2515 if buildenv in 'virtualenv': 2598 if buildenv in 'virtualenv':
2516 virtualenv_mapping = [ 2599 virtualenv_mapping = [
2517 ('name', 'home', ''), 2600 ('name', 'home', ''),
2518 ('clear', 'clear', False), 2601 ('clear', 'clear', False),
2519 ('use-distribute', 'useDistribute', False), 2602 ('use-distribute', 'useDistribute', False),
2520 ('system-site-packages', 'systemSitePackages', False)] 2603 ('system-site-packages', 'systemSitePackages', False),
2521 convert_mapping_to_xml(t, data, virtualenv_mapping, fail_required=True) 2604 ]
2605 helpers.convert_mapping_to_xml(
2606 t, data, virtualenv_mapping, fail_required=True)
2522 2607
2523 # Common arguments 2608 # Common arguments
2524 naturelist = ['shell', 'xshell', 'python'] 2609 naturelist = ['shell', 'xshell', 'python']
2525 mapping = [ 2610 mapping = [
2526 ('nature', 'nature', 'shell', naturelist), 2611 ('nature', 'nature', 'shell', naturelist),
2527 ('command', 'command', ""), 2612 ('command', 'command', ""),
2528 ('ignore-exit-code', 'ignoreExitCode', False)] 2613 ('ignore-exit-code', 'ignoreExitCode', False),
2529 convert_mapping_to_xml(t, data, mapping, fail_required=True) 2614 ]
2615 helpers.convert_mapping_to_xml(t, data, mapping, fail_required=True)
2530 2616
2531 2617
2532def tox(registry, xml_parent, data): 2618def tox(registry, xml_parent, data):
@@ -2551,7 +2637,7 @@ def tox(registry, xml_parent, data):
2551 ('ini', 'toxIni', 'tox.ini'), 2637 ('ini', 'toxIni', 'tox.ini'),
2552 ('recreate', 'recreate', False), 2638 ('recreate', 'recreate', False),
2553 ] 2639 ]
2554 convert_mapping_to_xml(t, data, mappings, fail_required=True) 2640 helpers.convert_mapping_to_xml(t, data, mappings, fail_required=True)
2555 pattern = data.get('toxenv-pattern') 2641 pattern = data.get('toxenv-pattern')
2556 if pattern: 2642 if pattern:
2557 XML.SubElement(t, 'toxenvPattern').text = pattern 2643 XML.SubElement(t, 'toxenvPattern').text = pattern
@@ -2591,8 +2677,10 @@ def managed_script(registry, xml_parent, data):
2591 raise InvalidAttributeError('type', step_type, ['script', 'batch']) 2677 raise InvalidAttributeError('type', step_type, ['script', 'batch'])
2592 ms = XML.SubElement(xml_parent, 2678 ms = XML.SubElement(xml_parent,
2593 'org.jenkinsci.plugins.managedscripts.' + step) 2679 'org.jenkinsci.plugins.managedscripts.' + step)
2594 mapping = [('script-id', script_tag, None)] 2680 mapping = [
2595 convert_mapping_to_xml(ms, data, mapping, fail_required=True) 2681 ('script-id', script_tag, None),
2682 ]
2683 helpers.convert_mapping_to_xml(ms, data, mapping, fail_required=True)
2596 args = XML.SubElement(ms, 'buildStepArgs') 2684 args = XML.SubElement(ms, 'buildStepArgs')
2597 for arg in data.get('args', []): 2685 for arg in data.get('args', []):
2598 XML.SubElement(args, 'string').text = arg 2686 XML.SubElement(args, 'string').text = arg
@@ -2712,7 +2800,8 @@ def cmake(registry, xml_parent, data):
2712 ('generator', 'generator', "Unix Makefiles"), 2800 ('generator', 'generator', "Unix Makefiles"),
2713 ('clean-build-dir', 'cleanBuild', False), 2801 ('clean-build-dir', 'cleanBuild', False),
2714 ] 2802 ]
2715 helpers.convert_mapping_to_xml(cmake, data, mapping, fail_required=True) 2803 helpers.convert_mapping_to_xml(
2804 cmake, data, mapping, fail_required=True)
2716 2805
2717 info = registry.get_plugin_info("CMake plugin") 2806 info = registry.get_plugin_info("CMake plugin")
2718 # Note: Assume latest version of plugin is preferred config format 2807 # Note: Assume latest version of plugin is preferred config format
@@ -2948,7 +3037,7 @@ def scan_build(registry, xml_parent, data):
2948 '-derivedDataPath $WORKSPACE/build'), 3037 '-derivedDataPath $WORKSPACE/build'),
2949 ('report-folder', 'outputFolderName', 'clangScanBuildReports'), 3038 ('report-folder', 'outputFolderName', 'clangScanBuildReports'),
2950 ] 3039 ]
2951 convert_mapping_to_xml(p, data, mappings, fail_required=True) 3040 helpers.convert_mapping_to_xml(p, data, mappings, fail_required=True)
2952 3041
2953 3042
2954def ssh_builder(registry, xml_parent, data): 3043def ssh_builder(registry, xml_parent, data):
@@ -2972,7 +3061,7 @@ def ssh_builder(registry, xml_parent, data):
2972 ('ssh-user-ip', 'siteName', None), 3061 ('ssh-user-ip', 'siteName', None),
2973 ('command', 'command', None), 3062 ('command', 'command', None),
2974 ] 3063 ]
2975 convert_mapping_to_xml(builder, data, mapping, fail_required=True) 3064 helpers.convert_mapping_to_xml(builder, data, mapping, fail_required=True)
2976 3065
2977 3066
2978def sonar(registry, xml_parent, data): 3067def sonar(registry, xml_parent, data):
@@ -3011,7 +3100,7 @@ def sonar(registry, xml_parent, data):
3011 ('java-opts', 'javaOpts', ''), 3100 ('java-opts', 'javaOpts', ''),
3012 ('additional-arguments', 'additionalArguments', ''), 3101 ('additional-arguments', 'additionalArguments', ''),
3013 ] 3102 ]
3014 convert_mapping_to_xml(sonar, data, mappings, fail_required=True) 3103 helpers.convert_mapping_to_xml(sonar, data, mappings, fail_required=True)
3015 if 'jdk' in data: 3104 if 'jdk' in data:
3016 XML.SubElement(sonar, 'jdk').text = data['jdk'] 3105 XML.SubElement(sonar, 'jdk').text = data['jdk']
3017 3106
@@ -3090,8 +3179,11 @@ def xcode(registry, xml_parent, data):
3090 if data.get('developer-profile'): 3179 if data.get('developer-profile'):
3091 profile = XML.SubElement(xml_parent, 'au.com.rayh.' 3180 profile = XML.SubElement(xml_parent, 'au.com.rayh.'
3092 'DeveloperProfileLoader') 3181 'DeveloperProfileLoader')
3093 mapping = [('developer-profile', 'id', None)] 3182 mapping = [
3094 convert_mapping_to_xml(profile, data, mapping, fail_required=False) 3183 ('developer-profile', 'id', None),
3184 ]
3185 helpers.convert_mapping_to_xml(
3186 profile, data, mapping, fail_required=False)
3095 3187
3096 xcode = XML.SubElement(xml_parent, 'au.com.rayh.XCodeBuilder') 3188 xcode = XML.SubElement(xml_parent, 'au.com.rayh.XCodeBuilder')
3097 3189
@@ -3113,7 +3205,7 @@ def xcode(registry, xml_parent, data):
3113 ('codesign-id', 'codeSigningIdentity', ''), 3205 ('codesign-id', 'codeSigningIdentity', ''),
3114 ('allow-failing', 'allowFailingBuildResults', False), 3206 ('allow-failing', 'allowFailingBuildResults', False),
3115 ] 3207 ]
3116 convert_mapping_to_xml(xcode, data, mappings, fail_required=True) 3208 helpers.convert_mapping_to_xml(xcode, data, mappings, fail_required=True)
3117 3209
3118 version = XML.SubElement(xcode, 'provideApplicationVersion') 3210 version = XML.SubElement(xcode, 'provideApplicationVersion')
3119 version_technical = XML.SubElement(xcode, 3211 version_technical = XML.SubElement(xcode,
@@ -3143,7 +3235,7 @@ def xcode(registry, xml_parent, data):
3143 ('keychain-password', 'keychainPwd', ''), 3235 ('keychain-password', 'keychainPwd', ''),
3144 ('keychain-unlock', 'unlockKeychain', False), 3236 ('keychain-unlock', 'unlockKeychain', False),
3145 ] 3237 ]
3146 convert_mapping_to_xml(xcode, data, mapping, fail_required=True) 3238 helpers.convert_mapping_to_xml(xcode, data, mapping, fail_required=True)
3147 3239
3148 has_provisioning_profiles = bool(data.get('provisioning-profiles')) 3240 has_provisioning_profiles = bool(data.get('provisioning-profiles'))
3149 XML.SubElement(xcode, 'manualSigning').text = str( 3241 XML.SubElement(xcode, 'manualSigning').text = str(
@@ -3153,12 +3245,12 @@ def xcode(registry, xml_parent, data):
3153 xcode, 'provisioningProfiles') 3245 xcode, 'provisioningProfiles')
3154 mapping = [ 3246 mapping = [
3155 ('bundle-id', 'provisioningProfileAppId', ''), 3247 ('bundle-id', 'provisioningProfileAppId', ''),
3156 ('provisioning-profile-uuid', 'provisioningProfileUUID', '') 3248 ('provisioning-profile-uuid', 'provisioningProfileUUID', ''),
3157 ] 3249 ]
3158 for provisioning_profile in data.get('provisioning-profiles'): 3250 for provisioning_profile in data.get('provisioning-profiles'):
3159 provisioning_profile_xml = XML.SubElement( 3251 provisioning_profile_xml = XML.SubElement(
3160 provisioning_profiles_xml, 'au.com.rayh.ProvisioningProfile') 3252 provisioning_profiles_xml, 'au.com.rayh.ProvisioningProfile')
3161 convert_mapping_to_xml(provisioning_profile_xml, 3253 helpers.convert_mapping_to_xml(provisioning_profile_xml,
3162 provisioning_profile, mapping, fail_required=True) 3254 provisioning_profile, mapping, fail_required=True)
3163 3255
3164 3256
@@ -3210,7 +3302,7 @@ def sonatype_clm(registry, xml_parent, data):
3210 ('value', 'value', 'list', SUPPORTED_VALUES), 3302 ('value', 'value', 'list', SUPPORTED_VALUES),
3211 ('application-name', 'applicationId', None), 3303 ('application-name', 'applicationId', None),
3212 ] 3304 ]
3213 convert_mapping_to_xml( 3305 helpers.convert_mapping_to_xml(
3214 application_select, data, application_mappings, fail_required=True) 3306 application_select, data, application_mappings, fail_required=True)
3215 3307
3216 path = XML.SubElement(clm, 'pathConfig') 3308 path = XML.SubElement(clm, 'pathConfig')
@@ -3219,7 +3311,8 @@ def sonatype_clm(registry, xml_parent, data):
3219 ('module-excludes', 'moduleExcludes', ''), 3311 ('module-excludes', 'moduleExcludes', ''),
3220 ('advanced-options', 'scanProperties', ''), 3312 ('advanced-options', 'scanProperties', ''),
3221 ] 3313 ]
3222 convert_mapping_to_xml(path, data, path_mappings, fail_required=True) 3314 helpers.convert_mapping_to_xml(
3315 path, data, path_mappings, fail_required=True)
3223 3316
3224 mappings = [ 3317 mappings = [
3225 ('fail-on-clm-server-failure', 'failOnClmServerFailures', False), 3318 ('fail-on-clm-server-failure', 'failOnClmServerFailures', False),
@@ -3227,7 +3320,7 @@ def sonatype_clm(registry, xml_parent, data):
3227 ('username', 'username', ''), 3320 ('username', 'username', ''),
3228 ('password', 'password', ''), 3321 ('password', 'password', ''),
3229 ] 3322 ]
3230 convert_mapping_to_xml(clm, data, mappings, fail_required=True) 3323 helpers.convert_mapping_to_xml(clm, data, mappings, fail_required=True)
3231 3324
3232 3325
3233def beaker(registry, xml_parent, data): 3326def beaker(registry, xml_parent, data):
@@ -3305,11 +3398,12 @@ def cloudformation(registry, xml_parent, data):
3305 .. literalinclude:: ../../tests/builders/fixtures/cloudformation.yaml 3398 .. literalinclude:: ../../tests/builders/fixtures/cloudformation.yaml
3306 :language: yaml 3399 :language: yaml
3307 """ 3400 """
3308 region_dict = cloudformation_region_dict() 3401 region_dict = helpers.cloudformation_region_dict()
3309 stacks = cloudformation_init(xml_parent, data, 'CloudFormationBuildStep') 3402 stacks = helpers.cloudformation_init(
3403 xml_parent, data, 'CloudFormationBuildStep')
3310 for stack in data: 3404 for stack in data:
3311 cloudformation_stack(xml_parent, stack, 'PostBuildStackBean', stacks, 3405 helpers.cloudformation_stack(
3312 region_dict) 3406 xml_parent, stack, 'PostBuildStackBean', stacks, region_dict)
3313 3407
3314 3408
3315def jms_messaging(registry, xml_parent, data): 3409def jms_messaging(registry, xml_parent, data):
@@ -3402,7 +3496,7 @@ def openshift_build_verify(registry, xml_parent, data):
3402 ("auth-token", 'authToken', ''), 3496 ("auth-token", 'authToken', ''),
3403 ("verbose", 'verbose', False), 3497 ("verbose", 'verbose', False),
3404 ] 3498 ]
3405 convert_mapping_to_xml(osb, data, mapping, fail_required=True) 3499 helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
3406 3500
3407 3501
3408def openshift_builder(registry, xml_parent, data): 3502def openshift_builder(registry, xml_parent, data):
@@ -3458,7 +3552,7 @@ def openshift_builder(registry, xml_parent, data):
3458 ("build-name", 'buildName', ''), 3552 ("build-name", 'buildName', ''),
3459 ("show-build-logs", 'showBuildLogs', False), 3553 ("show-build-logs", 'showBuildLogs', False),
3460 ] 3554 ]
3461 convert_mapping_to_xml(osb, data, mapping, fail_required=True) 3555 helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
3462 3556
3463 3557
3464def openshift_creator(registry, xml_parent, data): 3558def openshift_creator(registry, xml_parent, data):
@@ -3506,7 +3600,7 @@ def openshift_creator(registry, xml_parent, data):
3506 ("auth-token", 'authToken', ''), 3600 ("auth-token", 'authToken', ''),
3507 ("verbose", 'verbose', False), 3601 ("verbose", 'verbose', False),
3508 ] 3602 ]
3509 convert_mapping_to_xml(osb, data, mapping, fail_required=True) 3603 helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
3510 3604
3511 3605
3512def openshift_dep_verify(registry, xml_parent, data): 3606def openshift_dep_verify(registry, xml_parent, data):
@@ -3557,7 +3651,7 @@ def openshift_dep_verify(registry, xml_parent, data):
3557 ("auth-token", 'authToken', ''), 3651 ("auth-token", 'authToken', ''),
3558 ("verbose", 'verbose', False), 3652 ("verbose", 'verbose', False),
3559 ] 3653 ]
3560 convert_mapping_to_xml(osb, data, mapping, fail_required=True) 3654 helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
3561 3655
3562 3656
3563def openshift_deployer(registry, xml_parent, data): 3657def openshift_deployer(registry, xml_parent, data):
@@ -3603,7 +3697,7 @@ def openshift_deployer(registry, xml_parent, data):
3603 ("auth-token", 'authToken', ''), 3697 ("auth-token", 'authToken', ''),
3604 ("verbose", 'verbose', False), 3698 ("verbose", 'verbose', False),
3605 ] 3699 ]
3606 convert_mapping_to_xml(osb, data, mapping, fail_required=True) 3700 helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
3607 3701
3608 3702
3609def openshift_img_tagger(registry, xml_parent, data): 3703def openshift_img_tagger(registry, xml_parent, data):
@@ -3654,7 +3748,7 @@ def openshift_img_tagger(registry, xml_parent, data):
3654 ("auth-token", 'authToken', ''), 3748 ("auth-token", 'authToken', ''),
3655 ("verbose", 'verbose', False), 3749 ("verbose", 'verbose', False),
3656 ] 3750 ]
3657 convert_mapping_to_xml(osb, data, mapping, fail_required=True) 3751 helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
3658 3752
3659 3753
3660def openshift_scaler(registry, xml_parent, data): 3754def openshift_scaler(registry, xml_parent, data):
@@ -3701,7 +3795,7 @@ def openshift_scaler(registry, xml_parent, data):
3701 ("auth-token", 'authToken', ''), 3795 ("auth-token", 'authToken', ''),
3702 ("verbose", 'verbose', False), 3796 ("verbose", 'verbose', False),
3703 ] 3797 ]
3704 convert_mapping_to_xml(osb, data, mapping, fail_required=True) 3798 helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
3705 3799
3706 3800
3707def openshift_svc_verify(registry, xml_parent, data): 3801def openshift_svc_verify(registry, xml_parent, data):
@@ -3746,7 +3840,7 @@ def openshift_svc_verify(registry, xml_parent, data):
3746 ("auth-token", 'authToken', ''), 3840 ("auth-token", 'authToken', ''),
3747 ("verbose", 'verbose', False), 3841 ("verbose", 'verbose', False),
3748 ] 3842 ]
3749 convert_mapping_to_xml(osb, data, mapping, fail_required=True) 3843 helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
3750 3844
3751 3845
3752def runscope(registry, xml_parent, data): 3846def runscope(registry, xml_parent, data):
@@ -3777,7 +3871,7 @@ def runscope(registry, xml_parent, data):
3777 ('access-token', 'accessToken', None), 3871 ('access-token', 'accessToken', None),
3778 ('timeout', 'timeout', 60), 3872 ('timeout', 'timeout', 60),
3779 ] 3873 ]
3780 convert_mapping_to_xml(runscope, data, mapping, fail_required=True) 3874 helpers.convert_mapping_to_xml(runscope, data, mapping, fail_required=True)
3781 3875
3782 3876
3783def description_setter(registry, xml_parent, data): 3877def description_setter(registry, xml_parent, data):
@@ -3802,10 +3896,12 @@ def description_setter(registry, xml_parent, data):
3802 descriptionsetter = XML.SubElement( 3896 descriptionsetter = XML.SubElement(
3803 xml_parent, 3897 xml_parent,
3804 'hudson.plugins.descriptionsetter.DescriptionSetterBuilder') 3898 'hudson.plugins.descriptionsetter.DescriptionSetterBuilder')
3805 mapping = [('regexp', 'regexp', '')] 3899 mapping = [
3900 ('regexp', 'regexp', ''),
3901 ]
3806 if 'description' in data: 3902 if 'description' in data:
3807 mapping.append(('description', 'description', None)) 3903 mapping.append(('description', 'description', None))
3808 convert_mapping_to_xml( 3904 helpers.convert_mapping_to_xml(
3809 descriptionsetter, data, mapping, fail_required=True) 3905 descriptionsetter, data, mapping, fail_required=True)
3810 3906
3811 3907
@@ -3861,7 +3957,7 @@ def docker_build_publish(parse, xml_parent, data):
3861 ('file-path', 'dockerfilePath', ''), 3957 ('file-path', 'dockerfilePath', ''),
3862 ('build-context', 'buildContext', ''), 3958 ('build-context', 'buildContext', ''),
3863 ] 3959 ]
3864 convert_mapping_to_xml(db, data, mapping, fail_required=True) 3960 helpers.convert_mapping_to_xml(db, data, mapping, fail_required=True)
3865 3961
3866 mapping = [] 3962 mapping = []
3867 if 'server' in data: 3963 if 'server' in data:
@@ -3873,7 +3969,7 @@ def docker_build_publish(parse, xml_parent, data):
3873 3969
3874 if 'uri' in server_data: 3970 if 'uri' in server_data:
3875 mapping.append(('uri', 'uri', None)) 3971 mapping.append(('uri', 'uri', None))
3876 convert_mapping_to_xml( 3972 helpers.convert_mapping_to_xml(
3877 server, server_data, mapping, fail_required=True) 3973 server, server_data, mapping, fail_required=True)
3878 3974
3879 mappings = [] 3975 mappings = []
@@ -3886,7 +3982,7 @@ def docker_build_publish(parse, xml_parent, data):
3886 3982
3887 if 'url' in registry_data: 3983 if 'url' in registry_data:
3888 mappings.append(('url', 'url', None)) 3984 mappings.append(('url', 'url', None))
3889 convert_mapping_to_xml( 3985 helpers.convert_mapping_to_xml(
3890 registry, registry_data, mappings, fail_required=True) 3986 registry, registry_data, mappings, fail_required=True)
3891 3987
3892 3988
@@ -3927,7 +4023,7 @@ def build_name_setter(registry, xml_parent, data):
3927 ('macro', 'fromMacro', False), 4023 ('macro', 'fromMacro', False),
3928 ('macro-first', 'macroFirst', False), 4024 ('macro-first', 'macroFirst', False),
3929 ] 4025 ]
3930 convert_mapping_to_xml( 4026 helpers.convert_mapping_to_xml(
3931 build_name_setter, data, mapping, fail_required=True) 4027 build_name_setter, data, mapping, fail_required=True)
3932 4028
3933 4029
@@ -3983,7 +4079,7 @@ def nexus_artifact_uploader(registry, xml_parent, data):
3983 ('file', 'file', ''), 4079 ('file', 'file', ''),
3984 ('credentials_id', 'credentialsId', ''), 4080 ('credentials_id', 'credentialsId', ''),
3985 ] 4081 ]
3986 convert_mapping_to_xml( 4082 helpers.convert_mapping_to_xml(
3987 nexus_artifact_uploader, data, mapping, fail_required=True) 4083 nexus_artifact_uploader, data, mapping, fail_required=True)
3988 4084
3989 4085
@@ -4163,13 +4259,18 @@ def nodejs(parser, xml_parent, data):
4163 """ 4259 """
4164 nodejs = XML.SubElement(xml_parent, 4260 nodejs = XML.SubElement(xml_parent,
4165 'jenkins.plugins.nodejs.NodeJSCommandInterpreter') 4261 'jenkins.plugins.nodejs.NodeJSCommandInterpreter')
4166 mapping = [('script', 'command', None)] 4262 mapping = [
4263 ('script', 'command', None),
4264 ]
4167 4265
4168 mapping_opt = [('name', 'nodeJSInstallationName', None), 4266 mapping_opt = [
4169 ('config-id', 'configId', None)] 4267 ('name', 'nodeJSInstallationName', None),
4268 ('config-id', 'configId', None),
4269 ]
4170 4270
4171 convert_mapping_to_xml(nodejs, data, mapping, fail_required=True) 4271 helpers.convert_mapping_to_xml(nodejs, data, mapping, fail_required=True)
4172 convert_mapping_to_xml(nodejs, data, mapping_opt, fail_required=False) 4272 helpers.convert_mapping_to_xml(
4273 nodejs, data, mapping_opt, fail_required=False)
4173 4274
4174 4275
4175def xunit(registry, xml_parent, data): 4276def xunit(registry, xml_parent, data):