Refactor parameters.py
Converted all relevant functions to use helpers.<insert function> instead of a specific import. Added commas to last entries of mapping tuples. Signed-off-by: Tan Heng Yeow <E0032242@u.nus.edu> Change-Id: Ie7c40809ad8259fc3906871360c16dbb6e58a4b0
This commit is contained in:
parent
3b777009f3
commit
784d000d4b
|
@ -38,8 +38,7 @@ from jenkins_jobs.errors import JenkinsJobsException
|
||||||
from jenkins_jobs.errors import MissingAttributeError
|
from jenkins_jobs.errors import MissingAttributeError
|
||||||
from jenkins_jobs.errors import InvalidAttributeError
|
from jenkins_jobs.errors import InvalidAttributeError
|
||||||
import jenkins_jobs.modules.base
|
import jenkins_jobs.modules.base
|
||||||
from jenkins_jobs.modules.helpers import copyartifact_build_selector
|
import jenkins_jobs.modules.helpers as helpers
|
||||||
from jenkins_jobs.modules.helpers import convert_mapping_to_xml
|
|
||||||
|
|
||||||
|
|
||||||
def base_param(registry, xml_parent, data, do_default, ptype):
|
def base_param(registry, xml_parent, data, do_default, ptype):
|
||||||
|
@ -211,9 +210,9 @@ def label_param(registry, xml_parent, data):
|
||||||
|
|
||||||
valid_types = ['allCases', 'success', 'unstable']
|
valid_types = ['allCases', 'success', 'unstable']
|
||||||
mapping = [
|
mapping = [
|
||||||
('matching-label', 'triggerIfResult', 'allCases', valid_types)
|
('matching-label', 'triggerIfResult', 'allCases', valid_types),
|
||||||
]
|
]
|
||||||
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
helpers.convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||||
|
|
||||||
eligibility_label = data.get('node-eligibility', 'all').lower()
|
eligibility_label = data.get('node-eligibility', 'all').lower()
|
||||||
eligibility_label_dict = {
|
eligibility_label_dict = {
|
||||||
|
@ -387,8 +386,10 @@ def run_param(registry, xml_parent, data):
|
||||||
"""
|
"""
|
||||||
pdef = base_param(registry, xml_parent, data, False,
|
pdef = base_param(registry, xml_parent, data, False,
|
||||||
'hudson.model.RunParameterDefinition')
|
'hudson.model.RunParameterDefinition')
|
||||||
mapping = [('project-name', 'projectName', None)]
|
mapping = [
|
||||||
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
('project-name', 'projectName', None),
|
||||||
|
]
|
||||||
|
helpers.convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||||
|
|
||||||
|
|
||||||
def extended_choice_param(registry, xml_parent, data):
|
def extended_choice_param(registry, xml_parent, data):
|
||||||
|
@ -489,7 +490,7 @@ def extended_choice_param(registry, xml_parent, data):
|
||||||
('description-groovy-script', 'descriptionGroovyScript', ''),
|
('description-groovy-script', 'descriptionGroovyScript', ''),
|
||||||
('description-groovy-classpath', 'descriptionGroovyClasspath', ''),
|
('description-groovy-classpath', 'descriptionGroovyClasspath', ''),
|
||||||
]
|
]
|
||||||
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
helpers.convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||||
|
|
||||||
|
|
||||||
def validating_string_param(registry, xml_parent, data):
|
def validating_string_param(registry, xml_parent, data):
|
||||||
|
@ -521,7 +522,7 @@ def validating_string_param(registry, xml_parent, data):
|
||||||
('regex', 'regex', None),
|
('regex', 'regex', None),
|
||||||
('msg', 'failedValidationMessage', None),
|
('msg', 'failedValidationMessage', None),
|
||||||
]
|
]
|
||||||
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
helpers.convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||||
|
|
||||||
|
|
||||||
def svn_tags_param(registry, xml_parent, data):
|
def svn_tags_param(registry, xml_parent, data):
|
||||||
|
@ -564,7 +565,7 @@ def svn_tags_param(registry, xml_parent, data):
|
||||||
('sort-z-to-a', 'reverseByName', False),
|
('sort-z-to-a', 'reverseByName', False),
|
||||||
('', 'uuid', "1-1-1-1-1"),
|
('', 'uuid', "1-1-1-1-1"),
|
||||||
]
|
]
|
||||||
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
helpers.convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||||
|
|
||||||
|
|
||||||
def dynamic_choice_param(registry, xml_parent, data):
|
def dynamic_choice_param(registry, xml_parent, data):
|
||||||
|
@ -737,14 +738,14 @@ def dynamic_scriptler_param_common(registry, xml_parent, data, ptype):
|
||||||
'dynamicparameter.scriptler.'
|
'dynamicparameter.scriptler.'
|
||||||
'ScriptlerParameterDefinition_'
|
'ScriptlerParameterDefinition_'
|
||||||
'-ScriptParameter')
|
'-ScriptParameter')
|
||||||
convert_mapping_to_xml(
|
helpers.convert_mapping_to_xml(
|
||||||
parameterXML, parameter, mapping, fail_required=True)
|
parameterXML, parameter, mapping, fail_required=True)
|
||||||
mapping = [
|
mapping = [
|
||||||
('script-id', '__scriptlerScriptId', None),
|
('script-id', '__scriptlerScriptId', None),
|
||||||
('remote', '__remote', False),
|
('remote', '__remote', False),
|
||||||
('read-only', 'readonlyInputField', False),
|
('read-only', 'readonlyInputField', False),
|
||||||
]
|
]
|
||||||
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
helpers.convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||||
|
|
||||||
|
|
||||||
def matrix_combinations_param(registry, xml_parent, data):
|
def matrix_combinations_param(registry, xml_parent, data):
|
||||||
|
@ -772,8 +773,9 @@ def matrix_combinations_param(registry, xml_parent, data):
|
||||||
mapping = [
|
mapping = [
|
||||||
('name', 'name', None),
|
('name', 'name', None),
|
||||||
('description', 'description', ''),
|
('description', 'description', ''),
|
||||||
('filter', 'defaultCombinationFilter', '')]
|
('filter', 'defaultCombinationFilter', ''),
|
||||||
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
]
|
||||||
|
helpers.convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||||
|
|
||||||
return pdef
|
return pdef
|
||||||
|
|
||||||
|
@ -806,9 +808,9 @@ def copyartifact_build_selector_param(registry, xml_parent, data):
|
||||||
('name', 'name', None),
|
('name', 'name', None),
|
||||||
('description', 'description', ''),
|
('description', 'description', ''),
|
||||||
]
|
]
|
||||||
convert_mapping_to_xml(t, data, mapping, fail_required=True)
|
helpers.convert_mapping_to_xml(t, data, mapping, fail_required=True)
|
||||||
|
|
||||||
copyartifact_build_selector(t, data, 'defaultSelector')
|
helpers.copyartifact_build_selector(t, data, 'defaultSelector')
|
||||||
|
|
||||||
|
|
||||||
def maven_metadata_param(registry, xml_parent, data):
|
def maven_metadata_param(registry, xml_parent, data):
|
||||||
|
@ -860,7 +862,7 @@ def maven_metadata_param(registry, xml_parent, data):
|
||||||
('default-value', 'defaultValue', ''),
|
('default-value', 'defaultValue', ''),
|
||||||
('versions-filter', 'versionFilter', ''),
|
('versions-filter', 'versionFilter', ''),
|
||||||
]
|
]
|
||||||
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
helpers.convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||||
|
|
||||||
sort_order = data.get('sorting-order', 'descending').lower()
|
sort_order = data.get('sorting-order', 'descending').lower()
|
||||||
sort_dict = {'descending': 'DESC',
|
sort_dict = {'descending': 'DESC',
|
||||||
|
@ -875,7 +877,7 @@ def maven_metadata_param(registry, xml_parent, data):
|
||||||
('repository-username', 'username', ''),
|
('repository-username', 'username', ''),
|
||||||
('repository-password', 'password', ''),
|
('repository-password', 'password', ''),
|
||||||
]
|
]
|
||||||
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
helpers.convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||||
|
|
||||||
|
|
||||||
def hidden_param(parser, xml_parent, data):
|
def hidden_param(parser, xml_parent, data):
|
||||||
|
@ -928,7 +930,7 @@ def random_string_param(registry, xml_parent, data):
|
||||||
('description', 'description', ''),
|
('description', 'description', ''),
|
||||||
('failed-validation-message', 'failedValidationMessage', ''),
|
('failed-validation-message', 'failedValidationMessage', ''),
|
||||||
]
|
]
|
||||||
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
helpers.convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||||
|
|
||||||
|
|
||||||
def git_parameter_param(registry, xml_parent, data):
|
def git_parameter_param(registry, xml_parent, data):
|
||||||
|
@ -1034,7 +1036,7 @@ def git_parameter_param(registry, xml_parent, data):
|
||||||
('useRepository', 'useRepository', ''),
|
('useRepository', 'useRepository', ''),
|
||||||
('quickFilterEnabled', 'quickFilterEnabled', False),
|
('quickFilterEnabled', 'quickFilterEnabled', False),
|
||||||
]
|
]
|
||||||
convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
helpers.convert_mapping_to_xml(pdef, data, mapping, fail_required=True)
|
||||||
|
|
||||||
|
|
||||||
class Parameters(jenkins_jobs.modules.base.Base):
|
class Parameters(jenkins_jobs.modules.base.Base):
|
||||||
|
|
Loading…
Reference in New Issue