Package hudson.plugins.git.util
Class GitUtils
- java.lang.Object
-
- hudson.plugins.git.util.GitUtils
-
- All Implemented Interfaces:
Serializable
public class GitUtils extends Object implements Serializable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GitUtils(TaskListener listener, org.jenkinsci.plugins.gitclient.GitClient git)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<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>getAllBranchRevisions()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 Detail
-
GitUtils
public GitUtils(@NonNull TaskListener listener, @NonNull org.jenkinsci.plugins.gitclient.GitClient git)
-
-
Method Detail
-
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. Ifnull, default tool will be used (if exists)builtOn- Node for which the tool should be resolved Can beJenkins.getInstance()when running on controllerenv- Additional environment variableslistener- 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. Ifnull, default tool will be used (if exists)listener- Event listener- Returns:
- Tool installation or
nullif it cannot be resolved - Since:
- 4.0.0
-
getAllBranchRevisions
public Collection<hudson.plugins.git.Revision> getAllBranchRevisions() throws hudson.plugins.git.GitException, IOException, InterruptedException
Return 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 errorhudson.plugins.git.GitException- on git errorInterruptedException- when interrupted
-
getRevisionContainingBranch
public 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 errorhudson.plugins.git.GitException- on git errorInterruptedException- when interrupted
-
getRevisionForSHA1
public hudson.plugins.git.Revision getRevisionForSHA1(org.eclipse.jgit.lib.ObjectId sha1) throws hudson.plugins.git.GitException, IOException, InterruptedException- Throws:
hudson.plugins.git.GitExceptionIOExceptionInterruptedException
-
sortBranchesForRevision
public hudson.plugins.git.Revision sortBranchesForRevision(hudson.plugins.git.Revision revision, List<BranchSpec> branchOrder)
-
sortBranchesForRevision
public hudson.plugins.git.Revision sortBranchesForRevision(hudson.plugins.git.Revision revision, List<BranchSpec> branchOrder, EnvVars env)
-
filterTipBranches
@WithBridgeMethods(java.util.Collection.class) public 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 interruptedhudson.plugins.git.GitException
-
getPollEnvironment
public static EnvVars getPollEnvironment(AbstractProject p, FilePath ws, Launcher launcher, TaskListener listener) throws IOException, InterruptedException
- Throws:
IOExceptionInterruptedException
-
getPollEnvironment
public 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 consideredws- workspace to be consideredlauncher- launcher to use for calls to nodeslistener- build logreuseLastBuildEnv- 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 errorInterruptedException- when interrupted
-
-