diff options
author | Felipe Reyes <freyes@tty.cl> | 2013-10-01 18:33:06 -0300 |
---|---|---|
committer | Antoine Musso <hashar@free.fr> | 2013-11-14 14:02:18 +0100 |
commit | f9cdbfd4d3a0cc2909fb8d92b8e002aeb72fe84a (patch) | |
tree | 3e0c1986f1b34e28c1f99399e5bdd79040221dfd | |
parent | 894c72efcf07a6aae447b9502fc03e7957ff0530 (diff) | |
download | python-jenkins-job-builder-f9cdbfd4d3a0cc2909fb8d92b8e002aeb72fe84a.tar.gz python-jenkins-job-builder-f9cdbfd4d3a0cc2909fb8d92b8e002aeb72fe84a.tar.xz python-jenkins-job-builder-f9cdbfd4d3a0cc2909fb8d92b8e002aeb72fe84a.zip |
Added support for Git shallow clone parameter
Change-Id: Ia0251f25ff22fff10fe53ba6bf54f0e9072210fd
-rw-r--r-- | jenkins_jobs/modules/scm.py | 2 | ||||
-rw-r--r-- | tests/scm/__init__.py | 0 | ||||
-rw-r--r-- | tests/scm/fixtures/git-shallow-clone01.xml | 37 | ||||
-rw-r--r-- | tests/scm/fixtures/git-shallow-clone01.yaml | 8 | ||||
-rw-r--r-- | tests/scm/fixtures/git-shallow-clone02.xml | 37 | ||||
-rw-r--r-- | tests/scm/fixtures/git-shallow-clone02.yaml | 8 | ||||
-rw-r--r-- | tests/scm/fixtures/git-shallow-clone03.xml | 37 | ||||
-rw-r--r-- | tests/scm/fixtures/git-shallow-clone03.yaml | 7 | ||||
-rw-r--r-- | tests/scm/test_scm.py | 30 |
9 files changed, 166 insertions, 0 deletions
diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index 3ce34f68..03961fc5 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 00000000..e69de29b --- /dev/null +++ b/tests/scm/__init__.py diff --git a/tests/scm/fixtures/git-shallow-clone01.xml b/tests/scm/fixtures/git-shallow-clone01.xml new file mode 100644 index 00000000..d66862cd --- /dev/null +++ b/tests/scm/fixtures/git-shallow-clone01.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" ?> +<project> + <scm class="hudson.plugins.git.GitSCM"> + <configVersion>2</configVersion> + <userRemoteConfigs> + <hudson.plugins.git.UserRemoteConfig> + <name>origin</name> + <refspec>+refs/heads/*:refs/remotes/origin/*</refspec> + <url>https://github.com/openstack-infra/jenkins-job-builder.git</url> + </hudson.plugins.git.UserRemoteConfig> + </userRemoteConfigs> + <branches> + <hudson.plugins.git.BranchSpec> + <name>master</name> + </hudson.plugins.git.BranchSpec> + </branches> + <excludedUsers/> + <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/> + <disableSubmodules>false</disableSubmodules> + <recursiveSubmodules>false</recursiveSubmodules> + <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations> + <authorOrCommitter>false</authorOrCommitter> + <clean>true</clean> + <wipeOutWorkspace>true</wipeOutWorkspace> + <pruneBranches>false</pruneBranches> + <remotePoll>false</remotePoll> + <gitTool>Default</gitTool> + <submoduleCfg class="list"/> + <relativeTargetDir/> + <reference/> + <gitConfigName/> + <gitConfigEmail/> + <skipTag>false</skipTag> + <scmName/> + <useShallowClone>true</useShallowClone> + </scm> +</project> diff --git a/tests/scm/fixtures/git-shallow-clone01.yaml b/tests/scm/fixtures/git-shallow-clone01.yaml new file mode 100644 index 00000000..0e3d8343 --- /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 00000000..c1735f21 --- /dev/null +++ b/tests/scm/fixtures/git-shallow-clone02.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" ?> +<project> + <scm class="hudson.plugins.git.GitSCM"> + <configVersion>2</configVersion> + <userRemoteConfigs> + <hudson.plugins.git.UserRemoteConfig> + <name>origin</name> + <refspec>+refs/heads/*:refs/remotes/origin/*</refspec> + <url>https://github.com/openstack-infra/jenkins-job-builder.git</url> + </hudson.plugins.git.UserRemoteConfig> + </userRemoteConfigs> + <branches> + <hudson.plugins.git.BranchSpec> + <name>master</name> + </hudson.plugins.git.BranchSpec> + </branches> + <excludedUsers/> + <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/> + <disableSubmodules>false</disableSubmodules> + <recursiveSubmodules>false</recursiveSubmodules> + <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations> + <authorOrCommitter>false</authorOrCommitter> + <clean>true</clean> + <wipeOutWorkspace>true</wipeOutWorkspace> + <pruneBranches>false</pruneBranches> + <remotePoll>false</remotePoll> + <gitTool>Default</gitTool> + <submoduleCfg class="list"/> + <relativeTargetDir/> + <reference/> + <gitConfigName/> + <gitConfigEmail/> + <skipTag>false</skipTag> + <scmName/> + <useShallowClone>false</useShallowClone> + </scm> +</project> diff --git a/tests/scm/fixtures/git-shallow-clone02.yaml b/tests/scm/fixtures/git-shallow-clone02.yaml new file mode 100644 index 00000000..440f4783 --- /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 00000000..c1735f21 --- /dev/null +++ b/tests/scm/fixtures/git-shallow-clone03.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" ?> +<project> + <scm class="hudson.plugins.git.GitSCM"> + <configVersion>2</configVersion> + <userRemoteConfigs> + <hudson.plugins.git.UserRemoteConfig> + <name>origin</name> + <refspec>+refs/heads/*:refs/remotes/origin/*</refspec> + <url>https://github.com/openstack-infra/jenkins-job-builder.git</url> + </hudson.plugins.git.UserRemoteConfig> + </userRemoteConfigs> + <branches> + <hudson.plugins.git.BranchSpec> + <name>master</name> + </hudson.plugins.git.BranchSpec> + </branches> + <excludedUsers/> + <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/> + <disableSubmodules>false</disableSubmodules> + <recursiveSubmodules>false</recursiveSubmodules> + <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations> + <authorOrCommitter>false</authorOrCommitter> + <clean>true</clean> + <wipeOutWorkspace>true</wipeOutWorkspace> + <pruneBranches>false</pruneBranches> + <remotePoll>false</remotePoll> + <gitTool>Default</gitTool> + <submoduleCfg class="list"/> + <relativeTargetDir/> + <reference/> + <gitConfigName/> + <gitConfigEmail/> + <skipTag>false</skipTag> + <scmName/> + <useShallowClone>false</useShallowClone> + </scm> +</project> diff --git a/tests/scm/fixtures/git-shallow-clone03.yaml b/tests/scm/fixtures/git-shallow-clone03.yaml new file mode 100644 index 00000000..60e0b976 --- /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 00000000..f9eecef2 --- /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 |