From 0f45ba0351e1b088c1e5fb8cf117a43051b33fb2 Mon Sep 17 00:00:00 2001 From: Daniel Richardson Date: Wed, 16 May 2018 23:26:17 -0700 Subject: [PATCH] bug/2002053 allow None for auth-token auth-tokean as None type should exclude from the build job valuable for reuseing jobs that sometime need auth and othertimes don't Change-Id: I691e7dd4ff1af53efd9fac3363bce9d41038cf25 --- jenkins_jobs/modules/general.py | 5 +++-- tests/general/fixtures/authtoken001.xml | 9 +++++++++ tests/general/fixtures/authtoken001.yaml | 2 ++ tests/general/fixtures/authtoken002.xml | 10 ++++++++++ tests/general/fixtures/authtoken002.yaml | 2 ++ tests/general/fixtures/authtoken003.xml | 10 ++++++++++ tests/general/fixtures/authtoken003.yaml | 2 ++ 7 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/general/fixtures/authtoken001.xml create mode 100644 tests/general/fixtures/authtoken001.yaml create mode 100644 tests/general/fixtures/authtoken002.xml create mode 100644 tests/general/fixtures/authtoken002.yaml create mode 100644 tests/general/fixtures/authtoken003.xml create mode 100644 tests/general/fixtures/authtoken003.yaml diff --git a/jenkins_jobs/modules/general.py b/jenkins_jobs/modules/general.py index 0bfca5375..6a893afad 100644 --- a/jenkins_jobs/modules/general.py +++ b/jenkins_jobs/modules/general.py @@ -155,8 +155,9 @@ class General(jenkins_jobs.modules.base.Base): else: XML.SubElement(xml, 'blockBuildWhenUpstreamBuilding').text = 'false' - if 'auth-token' in data: - XML.SubElement(xml, 'authToken').text = data['auth-token'] + authtoken = data.get('auth-token', None) + if authtoken is not None: + XML.SubElement(xml, 'authToken').text = authtoken if data.get('concurrent'): XML.SubElement(xml, 'concurrentBuild').text = 'true' else: diff --git a/tests/general/fixtures/authtoken001.xml b/tests/general/fixtures/authtoken001.xml new file mode 100644 index 000000000..1505db519 --- /dev/null +++ b/tests/general/fixtures/authtoken001.xml @@ -0,0 +1,9 @@ + + + + false + false + false + false + true + diff --git a/tests/general/fixtures/authtoken001.yaml b/tests/general/fixtures/authtoken001.yaml new file mode 100644 index 000000000..f045a1246 --- /dev/null +++ b/tests/general/fixtures/authtoken001.yaml @@ -0,0 +1,2 @@ +project-type: freestyle +auth-token: diff --git a/tests/general/fixtures/authtoken002.xml b/tests/general/fixtures/authtoken002.xml new file mode 100644 index 000000000..f8c4db90a --- /dev/null +++ b/tests/general/fixtures/authtoken002.xml @@ -0,0 +1,10 @@ + + + + false + false + false + testvalue + false + true + diff --git a/tests/general/fixtures/authtoken002.yaml b/tests/general/fixtures/authtoken002.yaml new file mode 100644 index 000000000..aeff36bb5 --- /dev/null +++ b/tests/general/fixtures/authtoken002.yaml @@ -0,0 +1,2 @@ +project-type: freestyle +auth-token: 'testvalue' diff --git a/tests/general/fixtures/authtoken003.xml b/tests/general/fixtures/authtoken003.xml new file mode 100644 index 000000000..ea1b50e6e --- /dev/null +++ b/tests/general/fixtures/authtoken003.xml @@ -0,0 +1,10 @@ + + + + false + false + false + + false + true + diff --git a/tests/general/fixtures/authtoken003.yaml b/tests/general/fixtures/authtoken003.yaml new file mode 100644 index 000000000..f45d39c4f --- /dev/null +++ b/tests/general/fixtures/authtoken003.yaml @@ -0,0 +1,2 @@ +project-type: freestyle +auth-token: ''