From d7c37c89a810174afb05499a6a0142384cd1bf21 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Sat, 17 Jan 2015 11:45:44 -0500 Subject: [PATCH] Update SCM Wipe workspace to use extensions style Use the newer extensions style configuration for the SCM Wipe workspace option. This change simply changes the output style of this configuration leaving the original YAML configuration values in tact so it is backwards compatible with the old style configuration for wipe-workspace setting. While this patch still sets the old value long with the new extensions value. Jenkins appears to be happy with both values present and prefers the extensions format if it exists. This should allow the older Jenkins that only supports the older config format to continue to work. Change-Id: Ib5b1809d19a35f83f524ee84b18f0c58b851c70b Signed-off-by: Thanh Ha --- jenkins_jobs/modules/scm.py | 8 +++++++- tests/duplicates/fixtures/allow_duplicates001.xml | 4 +++- tests/duplicates/fixtures/allow_macros001.xml | 4 +++- tests/duplicates/fixtures/allow_projects001.xml | 4 +++- tests/duplicates/fixtures/allow_templates001.xml | 4 +++- tests/duplicates/fixtures/duplicates001.xml | 8 ++++++-- tests/duplicates/fixtures/duplicates002.xml | 8 ++++++-- tests/macros/scm/multi-scms001.xml | 8 ++++++-- tests/macros/scm/multi-scms002.xml | 4 +++- tests/macros/scm/scm002.xml | 4 +++- tests/scm/fixtures/git-ignore-notify01.xml | 4 +++- tests/scm/fixtures/git-ignore-notify02.xml | 4 +++- tests/scm/fixtures/git-ignore-notify03.xml | 4 +++- tests/scm/fixtures/git-multiple-remotes.xml | 4 +++- tests/scm/fixtures/git-shallow-clone01.xml | 4 +++- tests/scm/fixtures/git-shallow-clone02.xml | 4 +++- tests/scm/fixtures/git-shallow-clone03.xml | 4 +++- tests/scm/fixtures/git-submodule01.xml | 1 + tests/scm/fixtures/git001.xml | 1 + tests/scm/fixtures/git002.xml | 1 + tests/scm/fixtures/gitlab.xml | 4 +++- tests/scm/fixtures/local-branch001.xml | 4 +++- tests/scm/fixtures/stash.xml | 4 +++- tests/yamlparser/fixtures/complete001.xml | 4 +++- tests/yamlparser/fixtures/scm_remote_deep_bug.xml | 4 +++- 25 files changed, 82 insertions(+), 25 deletions(-) diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index 3be9d5a55..fff5a4f75 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -89,7 +89,6 @@ remoteName/\*') :arg str reference-repo: Path of the reference repo to use during clone (optional) :arg str scm-name: The unique scm name for this Git SCM (optional) - :arg bool wipe-workspace: Wipe out workspace before build (default true) :arg bool ignore-notify: Ignore notifyCommit URL accesses (default false) :arg str browser: what repository browser to use (default '(Auto)') :arg str browser-url: url for the repository browser (required if browser @@ -127,6 +126,8 @@ remoteName/\*') submodules operations (default: 10). :arg str timeout: Timeout for git commands in minutes (optional) + :arg bool wipe-workspace: Wipe out workspace before build + (default true) :browser values: :auto: @@ -294,6 +295,11 @@ remoteName/\*') 'hudson.plugins.git.extensions.impl.' 'CheckoutOption') XML.SubElement(co, 'timeout').text = str(data['timeout']) + # By default we wipe the workspace + wipe_workspace = str(data.get('wipe-workspace', True)).lower() + if wipe_workspace == 'true': + ext_name = 'hudson.plugins.git.extensions.impl.WipeWorkspace' + ext = XML.SubElement(exts_node, ext_name) browser = data.get('browser', 'auto') browserdict = {'auto': 'auto', diff --git a/tests/duplicates/fixtures/allow_duplicates001.xml b/tests/duplicates/fixtures/allow_duplicates001.xml index 7bc48b8c6..f2f666875 100644 --- a/tests/duplicates/fixtures/allow_duplicates001.xml +++ b/tests/duplicates/fixtures/allow_duplicates001.xml @@ -42,7 +42,9 @@ false false - + + + diff --git a/tests/duplicates/fixtures/allow_macros001.xml b/tests/duplicates/fixtures/allow_macros001.xml index 2fb2b2749..9fa9983db 100644 --- a/tests/duplicates/fixtures/allow_macros001.xml +++ b/tests/duplicates/fixtures/allow_macros001.xml @@ -42,7 +42,9 @@ false false - + + + diff --git a/tests/duplicates/fixtures/allow_projects001.xml b/tests/duplicates/fixtures/allow_projects001.xml index 23942c9e4..d515d2356 100644 --- a/tests/duplicates/fixtures/allow_projects001.xml +++ b/tests/duplicates/fixtures/allow_projects001.xml @@ -42,7 +42,9 @@ false false - + + + diff --git a/tests/duplicates/fixtures/allow_templates001.xml b/tests/duplicates/fixtures/allow_templates001.xml index 23942c9e4..d515d2356 100644 --- a/tests/duplicates/fixtures/allow_templates001.xml +++ b/tests/duplicates/fixtures/allow_templates001.xml @@ -42,7 +42,9 @@ false false - + + + diff --git a/tests/duplicates/fixtures/duplicates001.xml b/tests/duplicates/fixtures/duplicates001.xml index c7ead7a95..cae598f7e 100644 --- a/tests/duplicates/fixtures/duplicates001.xml +++ b/tests/duplicates/fixtures/duplicates001.xml @@ -42,7 +42,9 @@ false false - + + + @@ -92,7 +94,9 @@ false false - + + + diff --git a/tests/duplicates/fixtures/duplicates002.xml b/tests/duplicates/fixtures/duplicates002.xml index 0dccf9cee..01faa9307 100644 --- a/tests/duplicates/fixtures/duplicates002.xml +++ b/tests/duplicates/fixtures/duplicates002.xml @@ -42,7 +42,9 @@ false false - + + + @@ -92,7 +94,9 @@ false false - + + + diff --git a/tests/macros/scm/multi-scms001.xml b/tests/macros/scm/multi-scms001.xml index 433e8af49..84ef8e805 100644 --- a/tests/macros/scm/multi-scms001.xml +++ b/tests/macros/scm/multi-scms001.xml @@ -44,7 +44,9 @@ false false - + + + 2 @@ -80,7 +82,9 @@ false false - + + + diff --git a/tests/macros/scm/multi-scms002.xml b/tests/macros/scm/multi-scms002.xml index 517fe55af..af2b3e79c 100644 --- a/tests/macros/scm/multi-scms002.xml +++ b/tests/macros/scm/multi-scms002.xml @@ -56,7 +56,9 @@ false false - + + + diff --git a/tests/macros/scm/scm002.xml b/tests/macros/scm/scm002.xml index 69df57c62..be1932d3f 100644 --- a/tests/macros/scm/scm002.xml +++ b/tests/macros/scm/scm002.xml @@ -42,7 +42,9 @@ false false - + + + diff --git a/tests/scm/fixtures/git-ignore-notify01.xml b/tests/scm/fixtures/git-ignore-notify01.xml index 32fb2a67e..098c0a45d 100644 --- a/tests/scm/fixtures/git-ignore-notify01.xml +++ b/tests/scm/fixtures/git-ignore-notify01.xml @@ -34,6 +34,8 @@ false true - + + + diff --git a/tests/scm/fixtures/git-ignore-notify02.xml b/tests/scm/fixtures/git-ignore-notify02.xml index d2fe74cd3..cf7cb864c 100644 --- a/tests/scm/fixtures/git-ignore-notify02.xml +++ b/tests/scm/fixtures/git-ignore-notify02.xml @@ -34,6 +34,8 @@ false false - + + + diff --git a/tests/scm/fixtures/git-ignore-notify03.xml b/tests/scm/fixtures/git-ignore-notify03.xml index d2fe74cd3..cf7cb864c 100644 --- a/tests/scm/fixtures/git-ignore-notify03.xml +++ b/tests/scm/fixtures/git-ignore-notify03.xml @@ -34,6 +34,8 @@ false false - + + + diff --git a/tests/scm/fixtures/git-multiple-remotes.xml b/tests/scm/fixtures/git-multiple-remotes.xml index 18cbdf6e7..65831c7fc 100644 --- a/tests/scm/fixtures/git-multiple-remotes.xml +++ b/tests/scm/fixtures/git-multiple-remotes.xml @@ -40,6 +40,8 @@ false false - + + + diff --git a/tests/scm/fixtures/git-shallow-clone01.xml b/tests/scm/fixtures/git-shallow-clone01.xml index 4fced0d27..f3c2044eb 100644 --- a/tests/scm/fixtures/git-shallow-clone01.xml +++ b/tests/scm/fixtures/git-shallow-clone01.xml @@ -35,6 +35,8 @@ true false - + + + diff --git a/tests/scm/fixtures/git-shallow-clone02.xml b/tests/scm/fixtures/git-shallow-clone02.xml index d2fe74cd3..cf7cb864c 100644 --- a/tests/scm/fixtures/git-shallow-clone02.xml +++ b/tests/scm/fixtures/git-shallow-clone02.xml @@ -34,6 +34,8 @@ false false - + + + diff --git a/tests/scm/fixtures/git-shallow-clone03.xml b/tests/scm/fixtures/git-shallow-clone03.xml index d2fe74cd3..cf7cb864c 100644 --- a/tests/scm/fixtures/git-shallow-clone03.xml +++ b/tests/scm/fixtures/git-shallow-clone03.xml @@ -34,6 +34,8 @@ false false - + + + diff --git a/tests/scm/fixtures/git-submodule01.xml b/tests/scm/fixtures/git-submodule01.xml index de1ebcb7c..aa481fb6e 100644 --- a/tests/scm/fixtures/git-submodule01.xml +++ b/tests/scm/fixtures/git-submodule01.xml @@ -39,6 +39,7 @@ true 15 + diff --git a/tests/scm/fixtures/git001.xml b/tests/scm/fixtures/git001.xml index 66a29fd99..3ef61fbc2 100644 --- a/tests/scm/fixtures/git001.xml +++ b/tests/scm/fixtures/git001.xml @@ -41,6 +41,7 @@ 20 + http://github.com/foo/example.git diff --git a/tests/scm/fixtures/git002.xml b/tests/scm/fixtures/git002.xml index 61d9b41c6..5e1a6283b 100644 --- a/tests/scm/fixtures/git002.xml +++ b/tests/scm/fixtures/git002.xml @@ -47,6 +47,7 @@ 20 + http://github.com/foo/example.git diff --git a/tests/scm/fixtures/gitlab.xml b/tests/scm/fixtures/gitlab.xml index 3288d2039..9d871cf5a 100644 --- a/tests/scm/fixtures/gitlab.xml +++ b/tests/scm/fixtures/gitlab.xml @@ -34,7 +34,9 @@ false false - + + + https://gitlab.example.com/foo/bar/ 5.2 diff --git a/tests/scm/fixtures/local-branch001.xml b/tests/scm/fixtures/local-branch001.xml index d2d919f2c..838bf46dd 100644 --- a/tests/scm/fixtures/local-branch001.xml +++ b/tests/scm/fixtures/local-branch001.xml @@ -35,6 +35,8 @@ false false master - + + + diff --git a/tests/scm/fixtures/stash.xml b/tests/scm/fixtures/stash.xml index f347d2b29..a50f954ab 100644 --- a/tests/scm/fixtures/stash.xml +++ b/tests/scm/fixtures/stash.xml @@ -34,7 +34,9 @@ false false - + + + https://stash.example.com/projects/foo/repos/bar/ diff --git a/tests/yamlparser/fixtures/complete001.xml b/tests/yamlparser/fixtures/complete001.xml index 6fe64b899..fd10bed8d 100644 --- a/tests/yamlparser/fixtures/complete001.xml +++ b/tests/yamlparser/fixtures/complete001.xml @@ -42,7 +42,9 @@ false false - + + + http://review.openstack.org/gitweb?p=openstack-infra/jenkins-job-builder.git diff --git a/tests/yamlparser/fixtures/scm_remote_deep_bug.xml b/tests/yamlparser/fixtures/scm_remote_deep_bug.xml index e80600cc7..86a4a4b01 100644 --- a/tests/yamlparser/fixtures/scm_remote_deep_bug.xml +++ b/tests/yamlparser/fixtures/scm_remote_deep_bug.xml @@ -42,7 +42,9 @@ false false - + + +