Merge "Update trigger_remote to make use of convert_mapping_to_xml"

This commit is contained in:
Jenkins 2017-06-27 16:13:08 +00:00 committed by Gerrit Code Review
commit 13f122b11b

View File

@ -349,38 +349,24 @@ def trigger_remote(registry, xml_parent, data):
'org.jenkinsci.plugins.' 'org.jenkinsci.plugins.'
'ParameterizedRemoteTrigger.' 'ParameterizedRemoteTrigger.'
'RemoteBuildConfiguration') 'RemoteBuildConfiguration')
XML.SubElement(triggerr,
'remoteJenkinsName').text = data.get('remote-jenkins-name')
XML.SubElement(triggerr, 'token').text = data.get('token', '')
for attribute in ['job', 'remote-jenkins-name']: mappings = [
if attribute not in data: ('remote-jenkins-name', 'remoteJenkinsName', None),
raise MissingAttributeError(attribute, "builders.trigger-remote") ('token', 'token', ''),
if data[attribute] == '': ('job', 'job', None),
raise InvalidAttributeError(attribute, ('should-not-fail-build', 'shouldNotFailBuild', False),
data[attribute], ('poll-interval', 'pollInterval', 10),
"builders.trigger-remote") ('connection-retry-limit', 'connectionRetryLimit', 5),
('prevent-remote-build-queue', 'preventRemoteBuildQueue', False),
XML.SubElement(triggerr, 'job').text = data.get('job') ('block', 'blockBuildUntilComplete', True),
]
XML.SubElement(triggerr, 'shouldNotFailBuild').text = str( convert_mapping_to_xml(triggerr, data, mappings, fail_required=True)
data.get('should-not-fail-build', False)).lower()
XML.SubElement(triggerr,
'pollInterval').text = str(data.get('poll-interval', 10))
XML.SubElement(triggerr, 'connectionRetryLimit').text = str(
data.get('connection-retry-limit', 5))
XML.SubElement(triggerr, 'preventRemoteBuildQueue').text = str(
data.get('prevent-remote-build-queue', False)).lower()
XML.SubElement(triggerr, 'blockBuildUntilComplete').text = str(
data.get('block', True)).lower()
mappings = []
if 'predefined-parameters' in data: if 'predefined-parameters' in data:
parameters = XML.SubElement(triggerr, 'parameters') parameters = data.get('predefined-parameters', '')
parameters.text = data.get('predefined-parameters', '') XML.SubElement(triggerr, 'parameters').text = parameters
params_list = parameters.text.split("\n") params_list = parameters.split("\n")
parameter_list = XML.SubElement(triggerr, 'parameterList') parameter_list = XML.SubElement(triggerr, 'parameterList')
for param in params_list: for param in params_list:
@ -390,13 +376,14 @@ def trigger_remote(registry, xml_parent, data):
tmp.text = param tmp.text = param
if 'property-file' in data and data['property-file'] != '': if 'property-file' in data and data['property-file'] != '':
XML.SubElement(triggerr, 'loadParamsFromFile').text = 'true' mappings.append(('', 'loadParamsFromFile', 'true'))
XML.SubElement(triggerr, mappings.append(('property-file', 'parameterFile', None))
'parameterFile').text = data.get('property-file')
else: else:
XML.SubElement(triggerr, 'loadParamsFromFile').text = 'false' mappings.append(('', 'loadParamsFromFile', 'false'))
XML.SubElement(triggerr, 'overrideAuth').text = "false" mappings.append(('', 'overrideAuth', 'false'))
convert_mapping_to_xml(triggerr, data, mappings, fail_required=True)
def trigger_builds(registry, xml_parent, data): def trigger_builds(registry, xml_parent, data):