Skip to content
Permalink
Browse files

[JENKINS-35687] Add simple git lfs support

  • Loading branch information...
matthauck authored and creste committed Jun 14, 2016
1 parent 6e13431 commit a809052a9b8d59975477e52f106383d63b869830
@@ -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";
}
}
}
@@ -95,6 +95,11 @@ public CheckoutCommand sparseCheckoutPaths(List<String> sparseCheckoutPaths) {
throw new UnsupportedOperationException("Don't call me");
}

@Override
public CheckoutCommand lfsRemote(String lfsRemote) {
throw new UnsupportedOperationException("Don't call me");
}

@Override
public void execute() throws GitException, InterruptedException {
throw new UnsupportedOperationException("Don't call me");

0 comments on commit a809052

Please sign in to comment.
You can’t perform that action at this time.