Skip to content

Commit

Permalink
Add sparseCheckout symbol for Pipeline (jenkinsci#1638)
Browse files Browse the repository at this point in the history
Includes a test that confirms the sparseCheckout syntax works as expected.

Tested interactively to confirm that the new symbol behaves the same as
the old syntax behaved.  Does not include detailed functional testing
that the sparseCheckout symbol works as expected, since there are already
tests of sparse checkout in other tests.
  • Loading branch information
MarkEWaite committed Aug 20, 2024
1 parent 1ee3d21 commit da6948a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
12 changes: 11 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ This removes remote tracking branches and tags from the local workspace if they
----
checkout scmGit(
branches: [[name: 'master']],
extensions: [pruneStaleBranch(), pruneTags(true)],
extensions: [ pruneStaleBranch(), pruneTags(true) ],
userRemoteConfigs: [[url: 'https://github.com/jenkinsci/ws-cleanup-plugin']])
----

Expand Down Expand Up @@ -1058,6 +1058,16 @@ Path::

File or directory to be included in the checkout

[source,groovy]
----
checkout scmGit(
branches: [[name: 'master']],
extensions: [
sparseCheckout(sparseCheckoutPaths: [[path: 'src'], [path: 'Makefile']])
],
userRemoteConfigs: [[url: 'https://github.com/jenkinsci/git-plugin.git']])
----

[#git-lfs-pull-after-checkout]
==== Git LFS pull after checkout

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jenkinsci.plugins.gitclient.GitClient;
import org.jenkinsci.plugins.gitclient.UnsupportedCommand;
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import edu.umd.cs.findbugs.annotations.NonNull;

Expand Down Expand Up @@ -52,10 +53,11 @@ public void determineSupportForJGit(GitSCM scm, @NonNull UnsupportedCommand cmd)
}

@Extension
@Symbol("sparseCheckout")
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
@Override
public String getDisplayName() {
return "Sparse Checkout paths";
return "Sparse checkout paths";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ private String randomPipelineExtensions() {
"pruneTags()",
"pruneTags(false)",
"pruneTags(true)",
"sparseCheckout(sparseCheckoutPaths: [[path: 'src'], [path: 'Makefile']])",
"submodule(disableSubmodules: true)",
"submodule(depth: 1, shallow: true)",
"submodule(parentCredentials: true, recursiveSubmodules: true, threads: 13)",
Expand Down

0 comments on commit da6948a

Please sign in to comment.