diff --git a/README.adoc b/README.adoc index 548b5924fa..2477ae8fee 100644 --- a/README.adoc +++ b/README.adoc @@ -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']]) ---- @@ -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 diff --git a/src/main/java/hudson/plugins/git/extensions/impl/SparseCheckoutPaths.java b/src/main/java/hudson/plugins/git/extensions/impl/SparseCheckoutPaths.java index 0a8796f1d7..c5a326a837 100644 --- a/src/main/java/hudson/plugins/git/extensions/impl/SparseCheckoutPaths.java +++ b/src/main/java/hudson/plugins/git/extensions/impl/SparseCheckoutPaths.java @@ -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; @@ -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"; } } diff --git a/src/test/java/hudson/plugins/git/CredentialsUserRemoteConfigTest.java b/src/test/java/hudson/plugins/git/CredentialsUserRemoteConfigTest.java index 5e198345db..7efa4bb3ae 100644 --- a/src/test/java/hudson/plugins/git/CredentialsUserRemoteConfigTest.java +++ b/src/test/java/hudson/plugins/git/CredentialsUserRemoteConfigTest.java @@ -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)",