diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index d8244eae1..3f6f79e44 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -791,6 +791,10 @@ def svn(registry, xml_parent, data): and exclusion patterns for displaying changelog entries as it does for polling for changes (default false) :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) :Repo: @@ -842,6 +846,23 @@ def svn(registry, xml_parent, data): populate_repo_xml(locations, data) else: 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') if updater == 'wipeworkspace': updaterclass = 'CheckoutUpdater' diff --git a/tests/scm/fixtures/svn-additional-credentials-001.xml b/tests/scm/fixtures/svn-additional-credentials-001.xml new file mode 100644 index 000000000..fd31fe964 --- /dev/null +++ b/tests/scm/fixtures/svn-additional-credentials-001.xml @@ -0,0 +1,33 @@ + + + + + + http://svn.example.com/repo + . + abcdef01234567890 + files + true + + + http://svn.example.com/repo2 + repo2 + infinity + false + + + + + test realm + abcdef01234567891 + + + test realm 2 + abcdef01234567892 + + + + false + false + + diff --git a/tests/scm/fixtures/svn-additional-credentials-001.yaml b/tests/scm/fixtures/svn-additional-credentials-001.yaml new file mode 100644 index 000000000..34383cf5a --- /dev/null +++ b/tests/scm/fixtures/svn-additional-credentials-001.yaml @@ -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"