diff options
author | Imran Malik <hayderimran7@gmail.com> | 2017-01-25 00:07:26 -0800 |
---|---|---|
committer | Kien Ha <kienha9922@gmail.com> | 2018-06-14 22:07:35 -0400 |
commit | 4167cc5dbd1ee46b09077ccc46f5b91060dc98a7 (patch) | |
tree | d54b959d687646e6ce23bb9d31ffec02e7a4ca5b | |
parent | 52d2db498445c20f2d43d674783666424063293c (diff) | |
download | python-jenkins-job-builder-4167cc5dbd1ee46b09077ccc46f5b91060dc98a7.tar.gz python-jenkins-job-builder-4167cc5dbd1ee46b09077ccc46f5b91060dc98a7.tar.xz python-jenkins-job-builder-4167cc5dbd1ee46b09077ccc46f5b91060dc98a7.zip |
Add depth option to git shallow-clone
- Use convert xml for shallow-clone and depth
Change-Id: I92d4bd2ded6db66bb608aed480e873e29e7b9474
-rw-r--r-- | jenkins_jobs/modules/scm.py | 7 | ||||
-rw-r--r-- | tests/macros/fixtures/scm/obj-in-scm-macro001.xml | 1 | ||||
-rw-r--r-- | tests/scm/fixtures/git-cloneoptions01.xml | 1 | ||||
-rw-r--r-- | tests/scm/fixtures/git-shallow-clone01.xml | 1 | ||||
-rw-r--r-- | tests/scm/fixtures/git-shallow-clone02.xml | 1 | ||||
-rw-r--r-- | tests/scm/fixtures/git001.xml | 1 | ||||
-rw-r--r-- | tests/scm/fixtures/git002.xml | 3 | ||||
-rw-r--r-- | tests/scm/fixtures/git002.yaml | 2 |
8 files changed, 14 insertions, 3 deletions
diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index 23ba7b67..c009957e 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -169,6 +169,7 @@ def git(registry, xml_parent, data): * **scm-name** (`string`) - The unique scm name for this Git SCM (optional) * **shallow-clone** (`bool`) - Perform shallow clone (default false) + * **depth** (`int`) - Set shallow clone depth (default 1) * **do-not-fetch-tags** (`bool`) - Perform a clone without tags (default false) * **sparse-checkout** (`dict`) @@ -381,8 +382,10 @@ def git(registry, xml_parent, data): ) if any(key in data for key in clone_options): clo = XML.SubElement(exts_node, impl_prefix + 'CloneOption') - XML.SubElement(clo, 'shallow').text = str( - data.get('shallow-clone', False)).lower() + clone_mapping = [ + ('shallow-clone', 'shallow', False), + ('depth', 'depth', 1)] + convert_mapping_to_xml(clo, data, clone_mapping, fail_required=True) if 'do-not-fetch-tags' in data: XML.SubElement(clo, 'noTags').text = str( data.get('do-not-fetch-tags', False)).lower() diff --git a/tests/macros/fixtures/scm/obj-in-scm-macro001.xml b/tests/macros/fixtures/scm/obj-in-scm-macro001.xml index e382ff61..9918f252 100644 --- a/tests/macros/fixtures/scm/obj-in-scm-macro001.xml +++ b/tests/macros/fixtures/scm/obj-in-scm-macro001.xml @@ -37,6 +37,7 @@ <hudson.plugins.git.extensions.impl.CleanBeforeCheckout/> <hudson.plugins.git.extensions.impl.CloneOption> <shallow>true</shallow> + <depth>1</depth> </hudson.plugins.git.extensions.impl.CloneOption> <hudson.plugins.git.extensions.impl.SubmoduleOption> <disableSubmodules>false</disableSubmodules> diff --git a/tests/scm/fixtures/git-cloneoptions01.xml b/tests/scm/fixtures/git-cloneoptions01.xml index 0de9fccc..722f773a 100644 --- a/tests/scm/fixtures/git-cloneoptions01.xml +++ b/tests/scm/fixtures/git-cloneoptions01.xml @@ -26,6 +26,7 @@ <extensions> <hudson.plugins.git.extensions.impl.CloneOption> <shallow>false</shallow> + <depth>1</depth> <noTags>true</noTags> </hudson.plugins.git.extensions.impl.CloneOption> <hudson.plugins.git.extensions.impl.WipeWorkspace/> diff --git a/tests/scm/fixtures/git-shallow-clone01.xml b/tests/scm/fixtures/git-shallow-clone01.xml index f2ffe1c7..a5532f90 100644 --- a/tests/scm/fixtures/git-shallow-clone01.xml +++ b/tests/scm/fixtures/git-shallow-clone01.xml @@ -28,6 +28,7 @@ <hudson.plugins.git.extensions.impl.CleanCheckout/> <hudson.plugins.git.extensions.impl.CloneOption> <shallow>true</shallow> + <depth>1</depth> </hudson.plugins.git.extensions.impl.CloneOption> <hudson.plugins.git.extensions.impl.WipeWorkspace/> </extensions> diff --git a/tests/scm/fixtures/git-shallow-clone02.xml b/tests/scm/fixtures/git-shallow-clone02.xml index 416929e4..641863d8 100644 --- a/tests/scm/fixtures/git-shallow-clone02.xml +++ b/tests/scm/fixtures/git-shallow-clone02.xml @@ -27,6 +27,7 @@ <hudson.plugins.git.extensions.impl.CleanCheckout/> <hudson.plugins.git.extensions.impl.CloneOption> <shallow>false</shallow> + <depth>1</depth> </hudson.plugins.git.extensions.impl.CloneOption> <hudson.plugins.git.extensions.impl.WipeWorkspace/> </extensions> diff --git a/tests/scm/fixtures/git001.xml b/tests/scm/fixtures/git001.xml index c0f3746f..e0ef687f 100644 --- a/tests/scm/fixtures/git001.xml +++ b/tests/scm/fixtures/git001.xml @@ -29,6 +29,7 @@ <extensions> <hudson.plugins.git.extensions.impl.CloneOption> <shallow>false</shallow> + <depth>1</depth> <timeout>20</timeout> </hudson.plugins.git.extensions.impl.CloneOption> <hudson.plugins.git.extensions.impl.CheckoutOption> diff --git a/tests/scm/fixtures/git002.xml b/tests/scm/fixtures/git002.xml index 3f487551..a036c056 100644 --- a/tests/scm/fixtures/git002.xml +++ b/tests/scm/fixtures/git002.xml @@ -34,7 +34,8 @@ </options> </hudson.plugins.git.extensions.impl.ChangelogToBranch> <hudson.plugins.git.extensions.impl.CloneOption> - <shallow>false</shallow> + <shallow>true</shallow> + <depth>3</depth> <noTags>false</noTags> <timeout>20</timeout> </hudson.plugins.git.extensions.impl.CloneOption> diff --git a/tests/scm/fixtures/git002.yaml b/tests/scm/fixtures/git002.yaml index c1d37a02..e77d4249 100644 --- a/tests/scm/fixtures/git002.yaml +++ b/tests/scm/fixtures/git002.yaml @@ -6,6 +6,8 @@ scm: - stable browser: githubweb browser-url: http://github.com/foo/example.git + shallow-clone: true + depth: 3 timeout: 20 do-not-fetch-tags: false changelog-against: |