diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py
index 3ce34f680..03961fc50 100644
--- a/jenkins_jobs/modules/scm.py
+++ b/jenkins_jobs/modules/scm.py
@@ -66,6 +66,7 @@ def git(self, xml_parent, data):
:arg str basedir: location relative to the workspace root to clone to
(default: workspace)
:arg bool skip-tag: Skip tagging
+ :arg bool shallow-clone: Perform shallow clone
:arg bool prune: Prune remote branches
:arg bool clean: Clean after checkout
:arg bool fastpoll: Use fast remote polling
@@ -131,6 +132,7 @@ def git(self, xml_parent, data):
("git-config-email", 'gitConfigEmail', ''),
('skip-tag', 'skipTag', False),
('scm-name', 'scmName', ''),
+ ("shallow-clone", "useShallowClone", False),
]
choosing_strategies = {
diff --git a/tests/scm/__init__.py b/tests/scm/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/scm/fixtures/git-shallow-clone01.xml b/tests/scm/fixtures/git-shallow-clone01.xml
new file mode 100644
index 000000000..d66862cdc
--- /dev/null
+++ b/tests/scm/fixtures/git-shallow-clone01.xml
@@ -0,0 +1,37 @@
+
+
+
+ 2
+
+
+ origin
+ +refs/heads/*:refs/remotes/origin/*
+ https://github.com/openstack-infra/jenkins-job-builder.git
+
+
+
+
+ master
+
+
+
+
+ false
+ false
+ false
+ false
+ true
+ true
+ false
+ false
+ Default
+
+
+
+
+
+ false
+
+ true
+
+
diff --git a/tests/scm/fixtures/git-shallow-clone01.yaml b/tests/scm/fixtures/git-shallow-clone01.yaml
new file mode 100644
index 000000000..0e3d83435
--- /dev/null
+++ b/tests/scm/fixtures/git-shallow-clone01.yaml
@@ -0,0 +1,8 @@
+# vim: sw=4 ts=4 et
+scm:
+ - git:
+ url: https://github.com/openstack-infra/jenkins-job-builder.git
+ branches:
+ - master
+ clean: true
+ shallow-clone: true
diff --git a/tests/scm/fixtures/git-shallow-clone02.xml b/tests/scm/fixtures/git-shallow-clone02.xml
new file mode 100644
index 000000000..c1735f217
--- /dev/null
+++ b/tests/scm/fixtures/git-shallow-clone02.xml
@@ -0,0 +1,37 @@
+
+
+
+ 2
+
+
+ origin
+ +refs/heads/*:refs/remotes/origin/*
+ https://github.com/openstack-infra/jenkins-job-builder.git
+
+
+
+
+ master
+
+
+
+
+ false
+ false
+ false
+ false
+ true
+ true
+ false
+ false
+ Default
+
+
+
+
+
+ false
+
+ false
+
+
diff --git a/tests/scm/fixtures/git-shallow-clone02.yaml b/tests/scm/fixtures/git-shallow-clone02.yaml
new file mode 100644
index 000000000..440f47830
--- /dev/null
+++ b/tests/scm/fixtures/git-shallow-clone02.yaml
@@ -0,0 +1,8 @@
+# vim: sw=4 ts=4 et
+scm:
+ - git:
+ url: https://github.com/openstack-infra/jenkins-job-builder.git
+ branches:
+ - master
+ clean: true
+ shallow-clone: false
diff --git a/tests/scm/fixtures/git-shallow-clone03.xml b/tests/scm/fixtures/git-shallow-clone03.xml
new file mode 100644
index 000000000..c1735f217
--- /dev/null
+++ b/tests/scm/fixtures/git-shallow-clone03.xml
@@ -0,0 +1,37 @@
+
+
+
+ 2
+
+
+ origin
+ +refs/heads/*:refs/remotes/origin/*
+ https://github.com/openstack-infra/jenkins-job-builder.git
+
+
+
+
+ master
+
+
+
+
+ false
+ false
+ false
+ false
+ true
+ true
+ false
+ false
+ Default
+
+
+
+
+
+ false
+
+ false
+
+
diff --git a/tests/scm/fixtures/git-shallow-clone03.yaml b/tests/scm/fixtures/git-shallow-clone03.yaml
new file mode 100644
index 000000000..60e0b9760
--- /dev/null
+++ b/tests/scm/fixtures/git-shallow-clone03.yaml
@@ -0,0 +1,7 @@
+# vim: sw=4 ts=4 et
+scm:
+ - git:
+ url: https://github.com/openstack-infra/jenkins-job-builder.git
+ branches:
+ - master
+ clean: true
diff --git a/tests/scm/test_scm.py b/tests/scm/test_scm.py
new file mode 100644
index 000000000..f9eecef25
--- /dev/null
+++ b/tests/scm/test_scm.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+#
+# Joint copyright:
+# - Copyright 2012,2013 Wikimedia Foundation
+# - Copyright 2012,2013 Antoine "hashar" Musso
+# - Copyright 2013 Arnaud Fabre
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import os
+from testscenarios.testcase import TestWithScenarios
+from testtools import TestCase
+from jenkins_jobs.modules import scm
+from tests.base import get_scenarios, BaseTestCase
+
+
+class TestCaseModuleScm(TestWithScenarios, TestCase, BaseTestCase):
+ fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures')
+ scenarios = get_scenarios(fixtures_path)
+ klass = scm.SCM