diff options
author | Joao Vale <jpvale@gmail.com> | 2014-01-23 19:35:34 +0000 |
---|---|---|
committer | Joao Vale <jpvale@gmail.com> | 2014-01-23 19:35:34 +0000 |
commit | 70e50c1ef55af88609e820f6508a2594b7824192 (patch) | |
tree | ae2278429b8a36a0dd848dbc13bf4ac69d4e1a61 | |
parent | 6b7162ea1852aff90b0b43c527d2df6028ff03e3 (diff) | |
download | python-jenkins-job-builder-70e50c1ef55af88609e820f6508a2594b7824192.tar.gz python-jenkins-job-builder-70e50c1ef55af88609e820f6508a2594b7824192.tar.xz python-jenkins-job-builder-70e50c1ef55af88609e820f6508a2594b7824192.zip |
Add support for credentials-id in git repositories.
Original change by Soren Hansen <Soren.Hansen@ril.com>
Change-Id: I2ad6d5b7d8a5cc89596c41463dc7906780b61515
-rw-r--r-- | jenkins_jobs/modules/scm.py | 3 | ||||
-rw-r--r-- | tests/scm/fixtures/git-shallow-clone01.xml | 1 | ||||
-rw-r--r-- | tests/scm/fixtures/git-shallow-clone01.yaml | 1 |
3 files changed, 5 insertions, 0 deletions
diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index f8bd9825..8a54e09b 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -52,6 +52,7 @@ def git(self, xml_parent, data): <https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin>`_ :arg str url: URL of the git repository + :arg str credentials-id: ID of credentials to use to connect (optional) :arg str refspec: refspec to fetch :arg str name: name to fetch :arg list(str) branches: list of branch specifiers to build @@ -158,6 +159,8 @@ def git(self, xml_parent, data): refspec = '+refs/heads/*:refs/remotes/origin/*' XML.SubElement(huser, 'refspec').text = refspec XML.SubElement(huser, 'url').text = data['url'] + if 'credentials-id' in data: + XML.SubElement(huser, 'credentialsId').text = data['credentials-id'] xml_branches = XML.SubElement(scm, 'branches') branches = data.get('branches', ['**']) for branch in branches: diff --git a/tests/scm/fixtures/git-shallow-clone01.xml b/tests/scm/fixtures/git-shallow-clone01.xml index dd001541..8dfe2f72 100644 --- a/tests/scm/fixtures/git-shallow-clone01.xml +++ b/tests/scm/fixtures/git-shallow-clone01.xml @@ -7,6 +7,7 @@ <name>origin</name> <refspec>+refs/heads/*:refs/remotes/origin/*</refspec> <url>https://github.com/openstack-infra/jenkins-job-builder.git</url> + <credentialsId>43ed1990-46e5-4ed0-bfda-8d83e5cdd65f</credentialsId> </hudson.plugins.git.UserRemoteConfig> </userRemoteConfigs> <branches> diff --git a/tests/scm/fixtures/git-shallow-clone01.yaml b/tests/scm/fixtures/git-shallow-clone01.yaml index 0e3d8343..bd22408c 100644 --- a/tests/scm/fixtures/git-shallow-clone01.yaml +++ b/tests/scm/fixtures/git-shallow-clone01.yaml @@ -2,6 +2,7 @@ scm: - git: url: https://github.com/openstack-infra/jenkins-job-builder.git + credentials-id: "43ed1990-46e5-4ed0-bfda-8d83e5cdd65f" branches: - master clean: true |