diff options
author | Thanh Ha <thanh.ha@linuxfoundation.org> | 2015-01-17 11:19:23 -0500 |
---|---|---|
committer | Thanh Ha <thanh.ha@linuxfoundation.org> | 2015-01-22 11:52:59 -0500 |
commit | 09bd39fd64e60274606ca7a3ee8a191991b0acb0 (patch) | |
tree | ddc6c5087b28fe846b8b55b66a7eb9ab63c5316c | |
parent | 4bf020e07e0dd938732a32eaeb40a67d939cbd94 (diff) | |
download | python-jenkins-job-builder-09bd39fd64e60274606ca7a3ee8a191991b0acb0.tar.gz python-jenkins-job-builder-09bd39fd64e60274606ca7a3ee8a191991b0acb0.tar.xz python-jenkins-job-builder-09bd39fd64e60274606ca7a3ee8a191991b0acb0.zip |
Update git-submodule configuration to new extension style
The Jenkins Git SCM plugin now uses extensions style configuration. This
patch adds support for the extensions format and deprecates the old
format.
Change-Id: I3ef144473142e23de859f38501f3561875fb44bf
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
-rw-r--r-- | jenkins_jobs/modules/scm.py | 49 | ||||
-rw-r--r-- | tests/scm/fixtures/git-submodule01.xml | 44 | ||||
-rw-r--r-- | tests/scm/fixtures/git-submodule01.yaml | 8 |
3 files changed, 100 insertions, 1 deletions
diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index 6b65560d..3be9d5a5 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -31,7 +31,7 @@ Example of multiple repositories in a single job: .. literalinclude:: /../../tests/macros/scm/multi-scms001.yaml """ - +import logging import xml.etree.ElementTree as XML import jenkins_jobs.modules.base from jenkins_jobs.errors import JenkinsJobsException @@ -74,8 +74,14 @@ remoteName/\*') :arg bool clean: Clean after checkout (default false) :arg bool fastpoll: Use fast remote polling (default false) :arg bool disable-submodules: Disable submodules (default false) + + .. deprecated:: 1.1.1. Please use submodule extension. + :arg bool recursive-submodules: Recursively update submodules (default false) + + .. deprecated:: 1.1.1. Please use submodule extension. + :arg bool use-author: Use author rather than committer in Jenkin's build changeset (default false) :arg str git-tool: The name of the Git installation to use (default @@ -106,6 +112,20 @@ remoteName/\*') * **branch** (`string`) - name of the branch to create create changelog against (default 'master') + :arg dict submodule: + :submodule: + * **disable** (`bool`) - By disabling support for submodules + you can still keep using basic git plugin functionality + and just have Jenkins to ignore submodules completely as + if they didn't exist. + * **recursive** (`bool`) - Retrieve all submodules recursively + (uses '--recursive' option which requires git>=1.6.5) + * **tracking** (`bool`) - Retrieve the tip of the configured + branch in .gitmodules (Uses '--remote' option which + requires git>=1.8.2) + * **timeout** (`int`) - Specify a timeout (in minutes) for + submodules operations (default: 10). + :arg str timeout: Timeout for git commands in minutes (optional) :browser values: @@ -131,6 +151,7 @@ remoteName/\*') .. literalinclude:: /../../tests/scm/fixtures/git001.yaml """ + logger = logging.getLogger("%s:git" % __name__) # XXX somebody should write the docs for those with option name = # None so we have a sensible name/key for it. @@ -219,6 +240,21 @@ remoteName/\*') for elem in mapping: (optname, xmlname, val) = elem[:3] + + # Throw warning for deprecated settings and skip + submodule_cfgs = ['disable-submodules', 'recursive-submodules'] + if optname in submodule_cfgs: + if 'submodule' in data: + logger.warn("'{0}' is deprecated and will be ignored in " + "favour of 'submodule'".format(optname)) + continue + + if optname in data: + logger.warn("'{0}' is deprecated, please convert to use the " + "'submodule' section instead as support for this " + "top level option will be removed in a future " + "release.".format(optname)) + attrs = {} if len(elem) >= 4: attrs = elem[3] @@ -242,6 +278,17 @@ remoteName/\*') change_branch = data['changelog-against'].get('branch', 'master') XML.SubElement(opts, 'compareRemote').text = change_remote XML.SubElement(opts, 'compareTarget').text = change_branch + if 'submodule' in data: + ext_name = 'hudson.plugins.git.extensions.impl.SubmoduleOption' + ext = XML.SubElement(exts_node, ext_name) + XML.SubElement(ext, 'disableSubmodules').text = str( + data['submodule'].get('disable', False)).lower() + XML.SubElement(ext, 'recursiveSubmodules').text = str( + data['submodule'].get('recursive', False)).lower() + XML.SubElement(ext, 'trackingSubmodules').text = str( + data['submodule'].get('tracking', False)).lower() + XML.SubElement(ext, 'timeout').text = str( + data['submodule'].get('timeout', 10)) if 'timeout' in data: co = XML.SubElement(exts_node, 'hudson.plugins.git.extensions.impl.' diff --git a/tests/scm/fixtures/git-submodule01.xml b/tests/scm/fixtures/git-submodule01.xml new file mode 100644 index 00000000..de1ebcb7 --- /dev/null +++ b/tests/scm/fixtures/git-submodule01.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<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>**</name> + </hudson.plugins.git.BranchSpec> + </branches> + <excludedUsers/> + <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/> + <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations> + <authorOrCommitter>false</authorOrCommitter> + <clean>false</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> + <ignoreNotifyCommit>false</ignoreNotifyCommit> + <extensions> + <hudson.plugins.git.extensions.impl.SubmoduleOption> + <disableSubmodules>true</disableSubmodules> + <recursiveSubmodules>true</recursiveSubmodules> + <trackingSubmodules>true</trackingSubmodules> + <timeout>15</timeout> + </hudson.plugins.git.extensions.impl.SubmoduleOption> + </extensions> + </scm> +</project> diff --git a/tests/scm/fixtures/git-submodule01.yaml b/tests/scm/fixtures/git-submodule01.yaml new file mode 100644 index 00000000..4e5220bb --- /dev/null +++ b/tests/scm/fixtures/git-submodule01.yaml @@ -0,0 +1,8 @@ +scm: + - git: + url: https://github.com/openstack-infra/jenkins-job-builder.git + submodule: + disable: true + recursive: true + tracking: true + timeout: 15 |