Package hudson.plugins.git.util
Class GitUtils
java.lang.Object
hudson.plugins.git.util.GitUtils
- All Implemented Interfaces:
- Serializable
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionGitUtils(TaskListener listener, org.jenkinsci.plugins.gitclient.GitClient git) 
- 
Method SummaryModifier and TypeMethodDescriptionList<hudson.plugins.git.Revision>filterTipBranches(Collection<hudson.plugins.git.Revision> revisions) Return a list of 'tip' branches (I.E.static String[]fixupNames(String[] names, String[] urls) Collection<hudson.plugins.git.Revision>Return a list of "Revisions" - where a revision knows about all the branch names that refer to a SHA1.static EnvVarsgetPollEnvironment(AbstractProject p, FilePath ws, Launcher launcher, TaskListener listener) static EnvVarsgetPollEnvironment(AbstractProject p, FilePath ws, Launcher launcher, TaskListener listener, boolean reuseLastBuildEnv) An attempt to generate at least semi-useful EnvVars for polling calls, based on previous build.hudson.plugins.git.RevisiongetRevisionContainingBranch(String branchName) Return the revision containing the branch name.hudson.plugins.git.RevisiongetRevisionForSHA1(org.eclipse.jgit.lib.ObjectId sha1) static hudson.plugins.git.GitToolresolveGitTool(String gitTool, Node builtOn, EnvVars env, TaskListener listener) Resolves Git Tool by name.static hudson.plugins.git.GitToolresolveGitTool(String gitTool, TaskListener listener) Resolves Git Tool by name in a node-agnostic way.hudson.plugins.git.RevisionsortBranchesForRevision(hudson.plugins.git.Revision revision, List<BranchSpec> branchOrder) hudson.plugins.git.RevisionsortBranchesForRevision(hudson.plugins.git.Revision revision, List<BranchSpec> branchOrder, EnvVars env) static NodeworkspaceToNode(FilePath workspace) 
- 
Constructor Details- 
GitUtilspublic GitUtils(@NonNull TaskListener listener, @NonNull org.jenkinsci.plugins.gitclient.GitClient git) 
 
- 
- 
Method Details- 
resolveGitTool@CheckForNull public static hudson.plugins.git.GitTool resolveGitTool(@CheckForNull String gitTool, @CheckForNull Node builtOn, @CheckForNull EnvVars env, @NonNull TaskListener listener) Resolves Git Tool by name.- Parameters:
- gitTool- Tool name. If- null, default tool will be used (if exists)
- builtOn- Node for which the tool should be resolved Can be- Jenkins.getInstance()when running on controller
- env- Additional environment variables
- listener- Event listener
- Returns:
- Tool installation or nullif it cannot be resolved
- Since:
- 4.0.0
 
- 
resolveGitTool@CheckForNull public static hudson.plugins.git.GitTool resolveGitTool(@CheckForNull String gitTool, @NonNull TaskListener listener) Resolves Git Tool by name in a node-agnostic way. UseresolveGitTool(String, Node, EnvVars, TaskListener)when the node is known- Parameters:
- gitTool- Tool name. If- null, default tool will be used (if exists)
- listener- Event listener
- Returns:
- Tool installation or nullif it cannot be resolved
- Since:
- 4.0.0
 
- 
workspaceToNode
- 
getAllBranchRevisionspublic Collection<hudson.plugins.git.Revision> getAllBranchRevisions() throws hudson.plugins.git.GitException, IOException, InterruptedExceptionReturn a list of "Revisions" - where a revision knows about all the branch names that refer to a SHA1.- Returns:
- list of revisions
- Throws:
- IOException- on input or output error
- hudson.plugins.git.GitException- on git error
- InterruptedException- when interrupted
 
- 
getRevisionContainingBranchpublic hudson.plugins.git.Revision getRevisionContainingBranch(String branchName) throws hudson.plugins.git.GitException, IOException, InterruptedException Return the revision containing the branch name.- Parameters:
- branchName- name of branch to be searched
- Returns:
- revision containing branchName
- Throws:
- IOException- on input or output error
- hudson.plugins.git.GitException- on git error
- InterruptedException- when interrupted
 
- 
getRevisionForSHA1public hudson.plugins.git.Revision getRevisionForSHA1(org.eclipse.jgit.lib.ObjectId sha1) throws hudson.plugins.git.GitException, IOException, InterruptedException - Throws:
- hudson.plugins.git.GitException
- IOException
- InterruptedException
 
- 
sortBranchesForRevisionpublic hudson.plugins.git.Revision sortBranchesForRevision(hudson.plugins.git.Revision revision, List<BranchSpec> branchOrder) 
- 
sortBranchesForRevisionpublic hudson.plugins.git.Revision sortBranchesForRevision(hudson.plugins.git.Revision revision, List<BranchSpec> branchOrder, EnvVars env) 
- 
filterTipBranchespublic List<hudson.plugins.git.Revision> filterTipBranches(Collection<hudson.plugins.git.Revision> revisions) throws hudson.plugins.git.GitException, InterruptedException Return a list of 'tip' branches (I.E. branches that aren't included entirely within another branch).- Parameters:
- revisions- branches to be included in the search for tip branches
- Returns:
- filtered tip branches
- Throws:
- InterruptedException- when interrupted
- hudson.plugins.git.GitException
 
- 
getPollEnvironmentpublic static EnvVars getPollEnvironment(AbstractProject p, FilePath ws, Launcher launcher, TaskListener listener) throws IOException, InterruptedException - Throws:
- IOException
- InterruptedException
 
- 
getPollEnvironmentpublic static EnvVars getPollEnvironment(AbstractProject p, FilePath ws, Launcher launcher, TaskListener listener, boolean reuseLastBuildEnv) throws IOException, InterruptedException An attempt to generate at least semi-useful EnvVars for polling calls, based on previous build. Cribbed from various places.- Parameters:
- p- abstract project to be considered
- ws- workspace to be considered
- launcher- launcher to use for calls to nodes
- listener- build log
- reuseLastBuildEnv- true if last build environment should be considered
- Returns:
- environment variables from previous build to be used for polling
- Throws:
- IOException- on input or output error
- InterruptedException- when interrupted
 
- 
fixupNames
 
-