summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jenkins_jobs/modules/scm.py3
-rw-r--r--tests/scm/fixtures/git-shallow-clone01.xml1
-rw-r--r--tests/scm/fixtures/git-shallow-clone01.yaml1
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