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

Since the 30.01.2017 the SVN plugin support additional-credentials, but the jenkins-job-builder can't generate this part:

<additionalCredentials>
     <hudson.scm.SubversionSCM_-AdditionalCredentials>
        <realm>...</realm>
        <credentialsId>...</credentialsId>
     </hudson.scm.SubversionSCM_-AdditionalCredentials>
     <hudson.scm.SubversionSCM_-AdditionalCredentials>
        <realm>...</realm>
        <credentialsId>...</credentialsId>
     </hudson.scm.SubversionSCM_-AdditionalCredentials>
</additionalCredentials>

Now you have optional 'additional-credentials' parameters.

Change-Id: I801cada4bd630242a216a1facc4abfc8d5378bcf
Task:4884
Story:2001152
This commit is contained in:
Jacqueline Haefke 2017-08-16 20:55:29 +01:00
parent b402d7800c
commit 88e4dfdc2c
3 changed files with 70 additions and 0 deletions

View File

@ -794,6 +794,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:
@ -845,6 +849,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"