Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-35687] Add simple git lfs support
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/main/java/hudson/plugins/git/extensions/impl/GitLFSPull.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package hudson.plugins.git.extensions.impl; | ||
|
||
import hudson.Extension; | ||
import hudson.model.Run; | ||
import hudson.model.TaskListener; | ||
import hudson.plugins.git.GitException; | ||
import hudson.plugins.git.GitSCM; | ||
import hudson.plugins.git.extensions.GitSCMExtension; | ||
import hudson.plugins.git.extensions.GitSCMExtensionDescriptor; | ||
|
||
import org.eclipse.jgit.transport.RemoteConfig; | ||
import org.jenkinsci.plugins.gitclient.CheckoutCommand; | ||
import org.jenkinsci.plugins.gitclient.GitClient; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
/** | ||
* git-lfs-pull after the checkout. | ||
* | ||
* @author Matt Hauck | ||
*/ | ||
public class GitLFSPull extends GitSCMExtension { | ||
@DataBoundConstructor | ||
public GitLFSPull() { | ||
} | ||
|
||
@Override | ||
public void decorateCheckoutCommand(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener, CheckoutCommand cmd) throws IOException, InterruptedException, GitException { | ||
listener.getLogger().println("Enabling Git LFS pull"); | ||
List<RemoteConfig> repos = scm.getParamExpandedRepos(build, listener); | ||
// repos should never be empty, but check anyway | ||
if (!repos.isEmpty()) { | ||
// Pull LFS files from the first configured repository. | ||
// Same technique is used in GitSCM and CLoneOption. | ||
// Assumes the passed in scm represents a single repository, or if | ||
// multiple repositories are in use, the first repository in the | ||
// configuration is treated as authoritative. | ||
// Git plugin does not support multiple independent repositories | ||
// in a single job definition. | ||
cmd.lfsRemote(repos.get(0).getName()); | ||
} | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends GitSCMExtensionDescriptor { | ||
@Override | ||
public String getDisplayName() { | ||
return "Git LFS pull after checkout"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters