Set reference repo under clone options

When we have cloneOptions in the generated with options like
tags and reference filled outside of cloneOptions,
The reference is not filled in the job configuration and this
option will not work as expected. reference should
alwasy be listed inside CloneOptions.

Change-Id: I519d3c42f1b32ab27243b0f5c592e3d41e3230bb
Signed-off-by: Vishal Bhoj <vishal.bhoj@linaro.org>
This commit is contained in:
Vishal Bhoj 2018-10-05 23:09:05 +05:30 committed by Thanh Ha
parent ec3080b5bc
commit e6398cf373
No known key found for this signature in database
GPG Key ID: B0CB27E00DA095AA
3 changed files with 42 additions and 0 deletions

View File

@ -447,6 +447,7 @@ def git_extensions(xml_parent, data):
"timeout",
"do-not-fetch-tags",
"honor-refspec",
"reference-repo",
)
if any(key in data for key in clone_options):
ext_name = impl_prefix + 'CloneOption'
@ -471,6 +472,8 @@ def git_extensions(xml_parent, data):
if 'honor-refspec' in data:
XML.SubElement(ext, 'honorRefspec').text = str(
data.get('honor-refspec', False)).lower()
if 'reference-repo' in data:
XML.SubElement(ext, 'reference').text = str(data['reference-repo'])
if not trait and 'sparse-checkout' in data:
ext_name = impl_prefix + 'SparseCheckoutPaths'
ext = XML.SubElement(xml_parent, ext_name)

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<scm class="hudson.plugins.git.GitSCM">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<name>origin</name>
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
<url>https://example.com/project.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>**</name>
</hudson.plugins.git.BranchSpec>
</branches>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<remotePoll>false</remotePoll>
<gitTool>Default</gitTool>
<submoduleCfg class="list"/>
<reference>/path/to/reference/repo.git</reference>
<gitConfigName/>
<gitConfigEmail/>
<extensions>
<hudson.plugins.git.extensions.impl.CloneOption>
<shallow>false</shallow>
<depth>1</depth>
<reference>/path/to/reference/repo.git</reference>
</hudson.plugins.git.extensions.impl.CloneOption>
<hudson.plugins.git.extensions.impl.WipeWorkspace/>
</extensions>
</scm>
</project>

View File

@ -0,0 +1,4 @@
scm:
- git:
url: https://example.com/project.git
reference-repo: /path/to/reference/repo.git