scm: introduce parent-credentials for git submodules

Jenkins Git plugin does not use your configured credentials for cloning
submodules, but you can told it to use credentials from parent
repository, by checking "Use credentials from default remote of parent
repository", and this "parent-credentials" will set that option.

So without this option jenkins git plugin will not be able to clone
submodules, if they are not public available.

The default value is "false", like in jenkins git plugin.

See-also: https://issues.jenkins-ci.org/browse/JENKINS-20941
Change-Id: I1cfb3f45bb082f538eff1a9e64a03be27f759a5f
Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
This commit is contained in:
Azat Khuzhin 2017-03-31 20:44:35 +03:00
parent 4f77324fea
commit 9e51beb804
4 changed files with 7 additions and 0 deletions

View File

@ -181,6 +181,8 @@ def git(registry, xml_parent, data):
* **tracking** (`bool`) - Retrieve the tip of the configured
branch in .gitmodules (Uses '\-\-remote' option which requires
git>=1.8.2)
* **parent-credentials** (`bool`) - Use credentials from default
remote of parent repository (default false).
* **reference-repo** (`str`) - Path of the reference repo to use
during clone (optional)
* **timeout** (`int`) - Specify a timeout (in minutes) for
@ -396,6 +398,8 @@ def git(registry, xml_parent, data):
data['submodule'].get('recursive', False)).lower()
XML.SubElement(ext, 'trackingSubmodules').text = str(
data['submodule'].get('tracking', False)).lower()
XML.SubElement(ext, 'parentCredentials').text = str(
data['submodule'].get('parent-credentials', False)).lower()
XML.SubElement(ext, 'reference').text = str(
data['submodule'].get('reference-repo', ''))
XML.SubElement(ext, 'timeout').text = str(

View File

@ -42,6 +42,7 @@
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>true</recursiveSubmodules>
<trackingSubmodules>false</trackingSubmodules>
<parentCredentials>false</parentCredentials>
<reference/>
<timeout>10</timeout>
</hudson.plugins.git.extensions.impl.SubmoduleOption>

View File

@ -26,6 +26,7 @@
<disableSubmodules>true</disableSubmodules>
<recursiveSubmodules>true</recursiveSubmodules>
<trackingSubmodules>true</trackingSubmodules>
<parentCredentials>true</parentCredentials>
<reference>/jenkins_home/.gitcache/submodules</reference>
<timeout>15</timeout>
</hudson.plugins.git.extensions.impl.SubmoduleOption>

View File

@ -5,5 +5,6 @@ scm:
disable: true
recursive: true
tracking: true
parent-credentials: true
reference-repo: /jenkins_home/.gitcache/submodules
timeout: 15