From 1799211e3e106efef2a9756b3eb5ef1af078db66 Mon Sep 17 00:00:00 2001 From: Kien Ha Date: Fri, 22 Jul 2016 13:16:35 -0400 Subject: [PATCH] Change default on fail_required parameter to True for convert xml If optional setting was set and then is removed, Jenkins will retain the last configured setting for the option. This is inconsistent as it is expected that Jenkins will revert back to its default setting. And so optional parameters should use default setting. That is, JJB will handle default setting if optional parameter is not set. Original issue: http://lists.openstack.org/pipermail/openstack-infra/2016-February/003746.html Change-Id: Iaf8684053f8a2a035467f13d91fe2f0a56be5906 Signed-off-by: Kien Ha --- jenkins_jobs/modules/helpers.py | 5 +---- jenkins_jobs/modules/publishers.py | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/jenkins_jobs/modules/helpers.py b/jenkins_jobs/modules/helpers.py index 725da2adb..964fb4696 100644 --- a/jenkins_jobs/modules/helpers.py +++ b/jenkins_jobs/modules/helpers.py @@ -589,7 +589,7 @@ def trigger_project(tconfigs, project_def, param_order=None): mapping, fail_required=True) -def convert_mapping_to_xml(parent, data, mapping, fail_required=False): +def convert_mapping_to_xml(parent, data, mapping, fail_required=True): """Convert mapping to XML fail_required affects the last parameter of the mapping field when it's @@ -624,12 +624,9 @@ def convert_mapping_to_xml(parent, data, mapping, fail_required=False): valid_dict = elem[3] # Use fail_required setting to allow support for optional parameters - # we will phase this out in the future as we rework plugins so that - # optional parameters use a default setting instead. if val is None and fail_required is True: raise MissingAttributeError(optname) - # (Deprecated) in the future we will default to fail_required True # if no value is provided then continue else leave it # up to the user if they want to use an empty XML tag if val is None and fail_required is False: diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 29dab8bf2..27b2b71b1 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -388,7 +388,8 @@ def mqtt(registry, xml_parent, data): 'EXACTLY_ONCE': '2'}), ('retain-message', 'retainMessage', False) ] - helpers.convert_mapping_to_xml(mqtt, data, mqtt_mapping) + helpers.convert_mapping_to_xml(mqtt, data, mqtt_mapping, + fail_required=False) def codecover(registry, xml_parent, data):