Added SparseCheckout trait to the git extentions

Change-Id: I01e01cf1f6c07220de7f05ae67ffee6a924f5d08
Task: #41625
This commit is contained in:
Igor Lakhtenkov 2021-01-20 17:11:40 +03:00
parent ba91e9165d
commit 05149cf329
8 changed files with 75 additions and 2 deletions

View File

@ -431,6 +431,8 @@ def bitbucket_scm(xml_parent, data):
* **before** (`bool`) - Clean the workspace before checkout
* **prune** (`bool`) - Prune remote branches (default false)
* **shallow-clone** (`bool`) - Perform shallow clone (default false)
* **sparse-checkout** (dict)
* **paths** (list) - List of paths to sparse checkout. (optional)
* **depth** (`int`) - Set shallow clone depth (default 1)
* **do-not-fetch-tags** (`bool`) - Perform a clone without tags
(default false)
@ -799,6 +801,8 @@ def git_scm(xml_parent, data):
* **before** (`bool`) - Clean the workspace before checkout
* **prune** (`bool`) - Prune remote branches (default false)
* **shallow-clone** (`bool`) - Perform shallow clone (default false)
* **sparse-checkout** (dict)
* **paths** (list) - List of paths to sparse checkout. (optional)
* **depth** (`int`) - Set shallow clone depth (default 1)
* **do-not-fetch-tags** (`bool`) - Perform a clone without tags
(default false)
@ -941,6 +945,8 @@ def github_scm(xml_parent, data):
* **before** (`bool`) - Clean the workspace before checkout
* **prune** (`bool`) - Prune remote branches (default false)
* **shallow-clone** (`bool`) - Perform shallow clone (default false)
* **sparse-checkout** (dict)
* **paths** (list) - List of paths to sparse checkout. (optional)
* **depth** (`int`) - Set shallow clone depth (default 1)
* **do-not-fetch-tags** (`bool`) - Perform a clone without tags
(default false)

View File

@ -633,9 +633,14 @@ def git_extensions(xml_parent, data):
if trait and skip_notifications:
trait_name = "com.cloudbees.jenkins.plugins.bitbucket.notifications.SkipNotificationsTrait"
XML.SubElement(xml_parent, trait_name)
if not trait and "sparse-checkout" in data:
if "sparse-checkout" in data:
ext_name = impl_prefix + "SparseCheckoutPaths"
ext = XML.SubElement(xml_parent, ext_name)
if trait:
trait_name = "SparseCheckoutPathsTrait"
tr = XML.SubElement(xml_parent, trait_prefix + trait_name)
ext = XML.SubElement(tr, "extension", {"class": ext_name})
else:
ext = XML.SubElement(xml_parent, ext_name)
sparse_co = XML.SubElement(ext, "sparseCheckoutPaths")
sparse_paths = data["sparse-checkout"].get("paths")
if sparse_paths is not None:

View File

@ -117,6 +117,21 @@
</extension>
</jenkins.plugins.git.traits.CloneOptionTrait>
<com.cloudbees.jenkins.plugins.bitbucket.notifications.SkipNotificationsTrait/>
<jenkins.plugins.git.traits.SparseCheckoutPathsTrait>
<extension class="hudson.plugins.git.extensions.impl.SparseCheckoutPaths">
<sparseCheckoutPaths>
<hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<path>path1</path>
</hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<path>path2</path>
</hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<path>path3</path>
</hudson.plugins.git.extensions.impl.SparseCheckoutPath>
</sparseCheckoutPaths>
</extension>
</jenkins.plugins.git.traits.SparseCheckoutPathsTrait>
<jenkins.plugins.git.traits.SubmoduleOptionTrait>
<extension class="hudson.plugins.git.extensions.impl.SubmoduleOption">
<disableSubmodules>false</disableSubmodules>

View File

@ -83,6 +83,11 @@ scm:
user: CI System
email: no-reply@ci.example.com
prune: true
sparse-checkout:
paths:
- "path1"
- "path2"
- "path3"
shallow-clone: true
depth: 3
do-not-fetch-tags: true

View File

@ -75,6 +75,21 @@
<timeout>100</timeout>
</extension>
</jenkins.plugins.git.traits.CloneOptionTrait>
<jenkins.plugins.git.traits.SparseCheckoutPathsTrait>
<extension class="hudson.plugins.git.extensions.impl.SparseCheckoutPaths">
<sparseCheckoutPaths>
<hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<path>path1</path>
</hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<path>path2</path>
</hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<path>path3</path>
</hudson.plugins.git.extensions.impl.SparseCheckoutPath>
</sparseCheckoutPaths>
</extension>
</jenkins.plugins.git.traits.SparseCheckoutPathsTrait>
<jenkins.plugins.git.traits.SubmoduleOptionTrait>
<extension class="hudson.plugins.git.extensions.impl.SubmoduleOption">
<disableSubmodules>false</disableSubmodules>

View File

@ -71,6 +71,12 @@ scm:
after: true
before: true
prune: true
local-branch: true
sparse-checkout:
paths:
- "path1"
- "path2"
- "path3"
shallow-clone: true
depth: 3
do-not-fetch-tags: true

View File

@ -99,6 +99,21 @@
</extension>
</jenkins.plugins.git.traits.CloneOptionTrait>
<com.cloudbees.jenkins.plugins.bitbucket.notifications.SkipNotificationsTrait/>
<jenkins.plugins.git.traits.SparseCheckoutPathsTrait>
<extension class="hudson.plugins.git.extensions.impl.SparseCheckoutPaths">
<sparseCheckoutPaths>
<hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<path>path1</path>
</hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<path>path2</path>
</hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<hudson.plugins.git.extensions.impl.SparseCheckoutPath>
<path>path3</path>
</hudson.plugins.git.extensions.impl.SparseCheckoutPath>
</sparseCheckoutPaths>
</extension>
</jenkins.plugins.git.traits.SparseCheckoutPathsTrait>
<jenkins.plugins.git.traits.SubmoduleOptionTrait>
<extension class="hudson.plugins.git.extensions.impl.SubmoduleOption">
<disableSubmodules>false</disableSubmodules>

View File

@ -79,6 +79,12 @@ scm:
user: CI System
email: no-reply@ci.example.com
prune: true
local-branch: true
sparse-checkout:
paths:
- "path1"
- "path2"
- "path3"
shallow-clone: true
depth: 3
do-not-fetch-tags: true