Merge "Add Support for a list of additional-credentials in the SVN-plugin"

This commit is contained in:
Jenkins 2017-10-06 15:07:50 +00:00 committed by Gerrit Code Review
commit bfa1ae56eb
3 changed files with 70 additions and 0 deletions

View File

@ -791,6 +791,10 @@ def svn(registry, xml_parent, data):
and exclusion patterns for displaying changelog entries as it does for and exclusion patterns for displaying changelog entries as it does for
polling for changes (default false) polling for changes (default false)
:arg list repos: list of repositories to checkout (optional) :arg list repos: list of repositories to checkout (optional)
:arg list additional-credentials: list of additional credentials (optional)
:Additional-Credentials:
* **realm** (`str`) -- realm to use
* **credentials-id** (`str`) -- optional ID of credentials to use
:arg str viewvc-url: URL of the svn web interface (optional) :arg str viewvc-url: URL of the svn web interface (optional)
:Repo: :Repo:
@ -842,6 +846,23 @@ def svn(registry, xml_parent, data):
populate_repo_xml(locations, 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")
def populate_additional_credential_xml(parent, data):
module = XML.SubElement(parent,
'hudson.scm.SubversionSCM_-AdditionalCredentials')
XML.SubElement(module, 'realm').text = data['realm']
if 'credentials-id' in data:
XML.SubElement(module, 'credentialsId').text = data[
'credentials-id']
if 'additional-credentials' in data:
additional_credentials = XML.SubElement(scm, 'additionalCredentials')
additional_credentials_data = data['additional-credentials']
for additional_credential in additional_credentials_data:
populate_additional_credential_xml(additional_credentials,
additional_credential)
updater = data.get('workspaceupdater', 'wipeworkspace') updater = data.get('workspaceupdater', 'wipeworkspace')
if updater == 'wipeworkspace': if updater == 'wipeworkspace':
updaterclass = 'CheckoutUpdater' updaterclass = 'CheckoutUpdater'

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<scm class="hudson.scm.SubversionSCM">
<locations>
<hudson.scm.SubversionSCM_-ModuleLocation>
<remote>http://svn.example.com/repo</remote>
<local>.</local>
<credentialsId>abcdef01234567890</credentialsId>
<depthOption>files</depthOption>
<ignoreExternalsOption>true</ignoreExternalsOption>
</hudson.scm.SubversionSCM_-ModuleLocation>
<hudson.scm.SubversionSCM_-ModuleLocation>
<remote>http://svn.example.com/repo2</remote>
<local>repo2</local>
<depthOption>infinity</depthOption>
<ignoreExternalsOption>false</ignoreExternalsOption>
</hudson.scm.SubversionSCM_-ModuleLocation>
</locations>
<additionalCredentials>
<hudson.scm.SubversionSCM_-AdditionalCredentials>
<realm>test realm</realm>
<credentialsId>abcdef01234567891</credentialsId>
</hudson.scm.SubversionSCM_-AdditionalCredentials>
<hudson.scm.SubversionSCM_-AdditionalCredentials>
<realm>test realm 2</realm>
<credentialsId>abcdef01234567892</credentialsId>
</hudson.scm.SubversionSCM_-AdditionalCredentials>
</additionalCredentials>
<workspaceUpdater class="hudson.scm.subversion.UpdateUpdater"/>
<ignoreDirPropChanges>false</ignoreDirPropChanges>
<filterChangelog>false</filterChangelog>
</scm>
</project>

View File

@ -0,0 +1,16 @@
scm:
- svn:
workspaceupdater: update
repos:
- url: http://svn.example.com/repo
basedir: .
credentials-id: "abcdef01234567890"
repo-depth: files
ignore-externals: true
- url: http://svn.example.com/repo2
basedir: repo2
additional-credentials:
- realm: "test realm"
credentials-id: "abcdef01234567891"
- realm: "test realm 2"
credentials-id: "abcdef01234567892"