Support for repo-depth and ignore-externals in svn plugin
Change-Id: I5f35536a936bde33b0a8c710b28ac5e81fcc6c8b
This commit is contained in:
parent
8839388aa3
commit
c20570f9d6
@ -39,7 +39,8 @@ Example of an empty ``scm``:
|
|||||||
import logging
|
import logging
|
||||||
import xml.etree.ElementTree as XML
|
import xml.etree.ElementTree as XML
|
||||||
import jenkins_jobs.modules.base
|
import jenkins_jobs.modules.base
|
||||||
from jenkins_jobs.errors import JenkinsJobsException
|
from jenkins_jobs.errors import (InvalidAttributeError,
|
||||||
|
JenkinsJobsException)
|
||||||
|
|
||||||
|
|
||||||
def git(parser, xml_parent, data):
|
def git(parser, xml_parent, data):
|
||||||
@ -499,6 +500,9 @@ def svn(parser, xml_parent, data):
|
|||||||
(default '.')
|
(default '.')
|
||||||
:arg str credentials-id: optional argument to specify the ID of credentials
|
:arg str credentials-id: optional argument to specify the ID of credentials
|
||||||
to use
|
to use
|
||||||
|
:arg str repo-depth: Repository depth. Can be one of 'infinity', 'empty',
|
||||||
|
'files', 'immediates' or 'unknown'. (default 'infinity')
|
||||||
|
:arg bool ignore-externals: Ignore Externals. (default false)
|
||||||
:arg str workspaceupdater: optional argument to specify
|
:arg str workspaceupdater: optional argument to specify
|
||||||
how to update the workspace (default wipeworkspace)
|
how to update the workspace (default wipeworkspace)
|
||||||
:arg list(str) excluded-users: list of users to ignore revisions from
|
:arg list(str) excluded-users: list of users to ignore revisions from
|
||||||
@ -518,8 +522,12 @@ def svn(parser, xml_parent, data):
|
|||||||
|
|
||||||
:Repo: * **url** (`str`) -- URL for the repository
|
:Repo: * **url** (`str`) -- URL for the repository
|
||||||
* **basedir** (`str`) -- Location relative to the workspace
|
* **basedir** (`str`) -- Location relative to the workspace
|
||||||
root to checkout to (default '.')
|
root to checkout to (default '.')
|
||||||
* **credentials-id** - optional ID of credentials to use
|
* **credentials-id** - optional ID of credentials to use
|
||||||
|
* **repo-depth** - Repository depth. Can be one of 'infinity',
|
||||||
|
'empty', 'files', 'immediates' or 'unknown'.
|
||||||
|
(default 'infinity')
|
||||||
|
* **ignore-externals** - Ignore Externals. (default false)
|
||||||
|
|
||||||
:workspaceupdater values:
|
:workspaceupdater values:
|
||||||
:wipeworkspace: - deletes the workspace before checking out
|
:wipeworkspace: - deletes the workspace before checking out
|
||||||
@ -538,24 +546,29 @@ def svn(parser, xml_parent, data):
|
|||||||
scm = XML.SubElement(xml_parent, 'scm', {'class':
|
scm = XML.SubElement(xml_parent, 'scm', {'class':
|
||||||
'hudson.scm.SubversionSCM'})
|
'hudson.scm.SubversionSCM'})
|
||||||
locations = XML.SubElement(scm, 'locations')
|
locations = XML.SubElement(scm, 'locations')
|
||||||
if 'repos' in data:
|
|
||||||
repos = data['repos']
|
def populate_repo_xml(parent, data):
|
||||||
for repo in repos:
|
module = XML.SubElement(parent,
|
||||||
module = XML.SubElement(locations,
|
|
||||||
'hudson.scm.SubversionSCM_-ModuleLocation')
|
|
||||||
XML.SubElement(module, 'remote').text = repo['url']
|
|
||||||
XML.SubElement(module, 'local').text = repo.get('basedir', '.')
|
|
||||||
if 'credentials-id' in repo:
|
|
||||||
XML.SubElement(module, 'credentialsId').text = repo[
|
|
||||||
'credentials-id']
|
|
||||||
elif 'url' in data:
|
|
||||||
module = XML.SubElement(locations,
|
|
||||||
'hudson.scm.SubversionSCM_-ModuleLocation')
|
'hudson.scm.SubversionSCM_-ModuleLocation')
|
||||||
XML.SubElement(module, 'remote').text = data['url']
|
XML.SubElement(module, 'remote').text = data['url']
|
||||||
XML.SubElement(module, 'local').text = data.get('basedir', '.')
|
XML.SubElement(module, 'local').text = data.get('basedir', '.')
|
||||||
if 'credentials-id' in data:
|
if 'credentials-id' in data:
|
||||||
XML.SubElement(module, 'credentialsId').text = data[
|
XML.SubElement(module, 'credentialsId').text = data[
|
||||||
'credentials-id']
|
'credentials-id']
|
||||||
|
repo_depths = ['infinity', 'empty', 'files', 'immediates', 'unknown']
|
||||||
|
repo_depth = data.get('repo-depth', 'infinity')
|
||||||
|
if repo_depth not in repo_depths:
|
||||||
|
raise InvalidAttributeError('repo_depth', repo_depth, repo_depths)
|
||||||
|
XML.SubElement(module, 'depthOption').text = repo_depth
|
||||||
|
XML.SubElement(module, 'ignoreExternalsOption').text = str(
|
||||||
|
data.get('ignore-externals', False)).lower()
|
||||||
|
|
||||||
|
if 'repos' in data:
|
||||||
|
repos = data['repos']
|
||||||
|
for repo in repos:
|
||||||
|
populate_repo_xml(locations, repo)
|
||||||
|
elif 'url' in data:
|
||||||
|
populate_repo_xml(locations, data)
|
||||||
else:
|
else:
|
||||||
raise JenkinsJobsException("A top level url or repos list must exist")
|
raise JenkinsJobsException("A top level url or repos list must exist")
|
||||||
updater = data.get('workspaceupdater', 'wipeworkspace')
|
updater = data.get('workspaceupdater', 'wipeworkspace')
|
||||||
|
@ -6,10 +6,14 @@
|
|||||||
<remote>http://svn.example.com/repo</remote>
|
<remote>http://svn.example.com/repo</remote>
|
||||||
<local>.</local>
|
<local>.</local>
|
||||||
<credentialsId>abcdef01234567890</credentialsId>
|
<credentialsId>abcdef01234567890</credentialsId>
|
||||||
|
<depthOption>files</depthOption>
|
||||||
|
<ignoreExternalsOption>true</ignoreExternalsOption>
|
||||||
</hudson.scm.SubversionSCM_-ModuleLocation>
|
</hudson.scm.SubversionSCM_-ModuleLocation>
|
||||||
<hudson.scm.SubversionSCM_-ModuleLocation>
|
<hudson.scm.SubversionSCM_-ModuleLocation>
|
||||||
<remote>http://svn.example.com/repo2</remote>
|
<remote>http://svn.example.com/repo2</remote>
|
||||||
<local>repo2</local>
|
<local>repo2</local>
|
||||||
|
<depthOption>infinity</depthOption>
|
||||||
|
<ignoreExternalsOption>false</ignoreExternalsOption>
|
||||||
</hudson.scm.SubversionSCM_-ModuleLocation>
|
</hudson.scm.SubversionSCM_-ModuleLocation>
|
||||||
</locations>
|
</locations>
|
||||||
<workspaceUpdater class="hudson.scm.subversion.UpdateUpdater"/>
|
<workspaceUpdater class="hudson.scm.subversion.UpdateUpdater"/>
|
||||||
|
@ -5,5 +5,7 @@ scm:
|
|||||||
- url: http://svn.example.com/repo
|
- url: http://svn.example.com/repo
|
||||||
basedir: .
|
basedir: .
|
||||||
credentials-id: "abcdef01234567890"
|
credentials-id: "abcdef01234567890"
|
||||||
|
repo-depth: files
|
||||||
|
ignore-externals: true
|
||||||
- url: http://svn.example.com/repo2
|
- url: http://svn.example.com/repo2
|
||||||
basedir: repo2
|
basedir: repo2
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
<remote>http://svn.apache.org/repos/asf/spamassassin/trunk</remote>
|
<remote>http://svn.apache.org/repos/asf/spamassassin/trunk</remote>
|
||||||
<local>.</local>
|
<local>.</local>
|
||||||
<credentialsId>abcdef01234567890</credentialsId>
|
<credentialsId>abcdef01234567890</credentialsId>
|
||||||
|
<depthOption>empty</depthOption>
|
||||||
|
<ignoreExternalsOption>true</ignoreExternalsOption>
|
||||||
</hudson.scm.SubversionSCM_-ModuleLocation>
|
</hudson.scm.SubversionSCM_-ModuleLocation>
|
||||||
</locations>
|
</locations>
|
||||||
<workspaceUpdater class="hudson.scm.subversion.CheckoutUpdater"/>
|
<workspaceUpdater class="hudson.scm.subversion.CheckoutUpdater"/>
|
||||||
|
@ -2,6 +2,8 @@ scm:
|
|||||||
- svn:
|
- svn:
|
||||||
url: http://svn.apache.org/repos/asf/spamassassin/trunk
|
url: http://svn.apache.org/repos/asf/spamassassin/trunk
|
||||||
credentials-id: "abcdef01234567890"
|
credentials-id: "abcdef01234567890"
|
||||||
|
repo-depth: empty
|
||||||
|
ignore-externals: true
|
||||||
workspaceupdater: wipeworkspace
|
workspaceupdater: wipeworkspace
|
||||||
included-regions:
|
included-regions:
|
||||||
- /region1/.*\.cpp
|
- /region1/.*\.cpp
|
||||||
|
Loading…
Reference in New Issue
Block a user