Package hudson.plugins.git.util
Class GitUtils
java.lang.Object
hudson.plugins.git.util.GitUtils
- All Implemented Interfaces:
Serializable
- See Also:
-
Constructor Summary
ConstructorDescriptionGitUtils
(TaskListener listener, org.jenkinsci.plugins.gitclient.GitClient git) -
Method Summary
Modifier 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 EnvVars
getPollEnvironment
(AbstractProject p, FilePath ws, Launcher launcher, TaskListener listener) static EnvVars
getPollEnvironment
(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.Revision
getRevisionContainingBranch
(String branchName) Return the revision containing the branch name.hudson.plugins.git.Revision
getRevisionForSHA1
(org.eclipse.jgit.lib.ObjectId sha1) static hudson.plugins.git.GitTool
resolveGitTool
(String gitTool, Node builtOn, EnvVars env, TaskListener listener) Resolves Git Tool by name.static hudson.plugins.git.GitTool
resolveGitTool
(String gitTool, TaskListener listener) Resolves Git Tool by name in a node-agnostic way.hudson.plugins.git.Revision
sortBranchesForRevision
(hudson.plugins.git.Revision revision, List<BranchSpec> branchOrder) hudson.plugins.git.Revision
sortBranchesForRevision
(hudson.plugins.git.Revision revision, List<BranchSpec> branchOrder, EnvVars env) static Node
workspaceToNode
(FilePath workspace)
-
Constructor Details
-
GitUtils
public 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. 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
null
if 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
null
if it cannot be resolved - Since:
- 4.0.0
-
workspaceToNode
-
getAllBranchRevisions
public 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 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.GitException
IOException
InterruptedException
-
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:
IOException
InterruptedException
-
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
-
fixupNames
-