Package jenkins.plugins.git
Class GitToolChooser
- java.lang.Object
-
- jenkins.plugins.git.GitToolChooser
-
public class GitToolChooser extends Object
A class which allows Git Plugin to choose a git implementation by estimating the size of a repository from a distance without requiring a local checkout.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GitToolChooser.RepositorySizeAPI
Other plugins can estimate the size of repository using this extension point The size is assumed to be in KiBs
-
Constructor Summary
Constructors Constructor Description GitToolChooser(String remoteName, Item projectContext, String credentialsId, hudson.plugins.git.GitTool gitExe, Node n, TaskListener listener, Boolean useJGit)
Instantiate class using the remote name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
clearRepositorySizeCache()
Clear the cache of repository sizes.String
getGitTool()
Recommend git tool to be used by the git clientstatic void
putRepositorySizeCache(String repoURL, long repoSize)
Insert an entry into the cache of repository sizes.hudson.plugins.git.GitTool
recommendGitToolOnAgent(hudson.plugins.git.GitTool userChoice)
-
-
-
Constructor Detail
-
GitToolChooser
public GitToolChooser(String remoteName, Item projectContext, String credentialsId, hudson.plugins.git.GitTool gitExe, Node n, TaskListener listener, Boolean useJGit) throws IOException, InterruptedException
Instantiate class using the remote name. It looks for a cached .git directory first, calculates the size if it is found else checks if the extension point has been implemented and asks for the size.- Parameters:
remoteName
- the repository urlprojectContext
- the context where repository size is being estimatedcredentialsId
- credential used to access the repository or null if no credential is requiredgitExe
- Git tool ('git', 'jgit', 'jgitapache') to be used as the default tooln
- A Jenkins agent used to check validity of git installationlistener
- TaskListener required by GitUtils.resolveGitTool()useJGit
- if true the JGit is allowed as an implementation- Throws:
IOException
- on errorInterruptedException
- on error
-
-
Method Detail
-
recommendGitToolOnAgent
public hudson.plugins.git.GitTool recommendGitToolOnAgent(hudson.plugins.git.GitTool userChoice)
-
getGitTool
public String getGitTool()
Recommend git tool to be used by the git client- Returns:
- git implementation recommendation in the form of a string
-
clearRepositorySizeCache
public static void clearRepositorySizeCache()
Clear the cache of repository sizes.
-
putRepositorySizeCache
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static void putRepositorySizeCache(String repoURL, long repoSize)
Insert an entry into the cache of repository sizes. For testing only - not to be used outside the git plugin.- Parameters:
repoURL
- repository URL to be added as a cache keyrepoSize
- repository size in kilobytes
-
-