diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py
index 23ba7b67e..c009957e7 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 e382ff61e..9918f252c 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 @@
true
+ 1
false
diff --git a/tests/scm/fixtures/git-cloneoptions01.xml b/tests/scm/fixtures/git-cloneoptions01.xml
index 0de9fccc9..722f773a7 100644
--- a/tests/scm/fixtures/git-cloneoptions01.xml
+++ b/tests/scm/fixtures/git-cloneoptions01.xml
@@ -26,6 +26,7 @@
false
+ 1
true
diff --git a/tests/scm/fixtures/git-shallow-clone01.xml b/tests/scm/fixtures/git-shallow-clone01.xml
index f2ffe1c75..a5532f902 100644
--- a/tests/scm/fixtures/git-shallow-clone01.xml
+++ b/tests/scm/fixtures/git-shallow-clone01.xml
@@ -28,6 +28,7 @@
true
+ 1
diff --git a/tests/scm/fixtures/git-shallow-clone02.xml b/tests/scm/fixtures/git-shallow-clone02.xml
index 416929e42..641863d87 100644
--- a/tests/scm/fixtures/git-shallow-clone02.xml
+++ b/tests/scm/fixtures/git-shallow-clone02.xml
@@ -27,6 +27,7 @@
false
+ 1
diff --git a/tests/scm/fixtures/git001.xml b/tests/scm/fixtures/git001.xml
index c0f3746fc..e0ef687f2 100644
--- a/tests/scm/fixtures/git001.xml
+++ b/tests/scm/fixtures/git001.xml
@@ -29,6 +29,7 @@
false
+ 1
20
diff --git a/tests/scm/fixtures/git002.xml b/tests/scm/fixtures/git002.xml
index 3f4875510..a036c0567 100644
--- a/tests/scm/fixtures/git002.xml
+++ b/tests/scm/fixtures/git002.xml
@@ -34,7 +34,8 @@
- false
+ true
+ 3
false
20
diff --git a/tests/scm/fixtures/git002.yaml b/tests/scm/fixtures/git002.yaml
index c1d37a02a..e77d42494 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: