diff options
author | Thanh Ha <thanh.ha@linuxfoundation.org> | 2016-08-18 16:51:52 -0400 |
---|---|---|
committer | Thanh Ha <thanh.ha@linuxfoundation.org> | 2016-08-19 11:12:54 -0400 |
commit | a4cc12611afb8e3253d22dc05d9185cc4e11faaf (patch) | |
tree | af0863051d059d84941ce7cecff7962e8e2d7ae6 /jenkins_jobs/modules/general.py | |
parent | 8c9c50b1f68774fc563fc17a9cfff501a1a7b812 (diff) | |
download | python-jenkins-job-builder-a4cc12611afb8e3253d22dc05d9185cc4e11faaf.tar.gz python-jenkins-job-builder-a4cc12611afb8e3253d22dc05d9185cc4e11faaf.tar.xz python-jenkins-job-builder-a4cc12611afb8e3253d22dc05d9185cc4e11faaf.zip |
Fix disabled always returning true
If disabled is configured to anything the existing code returns true.
Typically what was done to avoid this was to ensure disabled was
returned in the job as {obj:disabled} to keep the original type. However
if the user uses a JJB 'defaults', defaults always return a string so
{obj:disabled} does not receive a boolean it's expecting causing
disabled's value to always be a string which in code returns as true
always.
Change-Id: Ifd391945fbc7478a10d794e50a61559688c1a23e
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
Diffstat (limited to 'jenkins_jobs/modules/general.py')
-rw-r--r-- | jenkins_jobs/modules/general.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/jenkins_jobs/modules/general.py b/jenkins_jobs/modules/general.py index b1268c13..a4f378f3 100644 --- a/jenkins_jobs/modules/general.py +++ b/jenkins_jobs/modules/general.py @@ -127,12 +127,15 @@ class General(jenkins_jobs.modules.base.Base): description = XML.SubElement(xml, 'description') description.text = desc_text XML.SubElement(xml, 'keepDependencies').text = 'false' + + # Need to ensure we support the None parameter to allow disabled to + # remain the last setting if the user purposely adds and then removes + # the disabled parameter. + # See: http://lists.openstack.org/pipermail/openstack-infra/2016-March/003980.html # noqa disabled = data.get('disabled', None) if disabled is not None: - if disabled: - XML.SubElement(xml, 'disabled').text = 'true' - else: - XML.SubElement(xml, 'disabled').text = 'false' + XML.SubElement(xml, 'disabled').text = str(disabled).lower() + if 'display-name' in data: XML.SubElement(xml, 'displayName').text = data['display-name'] if data.get('block-downstream'): |