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