Package org.jenkinsci.plugins.gitclient
Class Git
- java.lang.Object
-
- org.jenkinsci.plugins.gitclient.Git
-
- All Implemented Interfaces:
Serializable
public class Git extends Object implements Serializable
Git repository access class. Provides local and remote access to a git repository through aGitClient
implementation. Current git implementations include either command line git ("git" -CliGitAPIImpl
) or JGit ("jgit" -JGitAPIImpl
). The command line git implementation requires a separately installed git program. The command line git implementation is the current reference implementation. The JGit implementation is bundled entirely within the git client plugin and does not require any external programs. The JGit implementation is not yet functionally complete, though it handles most use cases.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
USE_CLI
Constant which controls the default implementation to be used.
-
Constructor Summary
Constructors Constructor Description Git(TaskListener listener, EnvVars env)
Constructor for a Git object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GitClient
getClient()
GitClient
implementation.Git
in(FilePath repository)
Defines theFilePath
(remotable directory) containing the git repository which will be used.Git
in(File repository)
Defines the local directory containing the git repository which will be used.Git
using(String exe)
Set the (node/environment specific) git executable to be used.static Git
with(TaskListener listener, EnvVars env)
Fluent constructor for a Git object.
-
-
-
Field Detail
-
USE_CLI
public static final boolean USE_CLI
Constant which controls the default implementation to be used.USE_CLI=Boolean.valueOf(System.getProperty(Git.class.getName() + ".useCLI", "true"))
. Uses command line implementation (CliGitAPIImpl
) by default.
-
-
Constructor Detail
-
Git
public Git(TaskListener listener, EnvVars env)
Constructor for a Git object. EitherGit.with(listener, env)
ornew Git(listener, env)
can be used to construct a Git object.- Parameters:
listener
- aTaskListener
which can be used to monitor git implementation operationsenv
- aEnvVars
which provides environment values to the git implementation
-
-
Method Detail
-
with
public static Git with(TaskListener listener, EnvVars env)
Fluent constructor for a Git object. EitherGit.with(listener, env)
or newGit(listener, env)
can be used to construct a Git object.- Parameters:
listener
- aTaskListener
which can be used to monitor git implementation operationsenv
- aEnvVars
which provides environment values to the git implementation- Returns:
- a
Git
object for repository access
-
in
public Git in(File repository)
Defines the local directory containing the git repository which will be used. For repositories with a working directory, repository is the parent of the.git
directory. For bare repositories, repository is the parent of theobjects
directory.
-
in
public Git in(FilePath repository)
Defines theFilePath
(remotable directory) containing the git repository which will be used. For repositories with a working directory, repository is the parent of the.git
directory. For bare repositories, repository is the parent of theobjects
directory.
-
using
public Git using(String exe)
Set the (node/environment specific) git executable to be used. If not set, JGit implementation will be used. When default is used, it assumes the caller does not rely on unimplemented CLI methods.- Parameters:
exe
- either "git" or "jgit"- Returns:
Git
object for repository access
-
getClient
public GitClient getClient() throws IOException, InterruptedException
GitClient
implementation. TheGitClient
interface provides the key operations which can be performed on a git repository.- Returns:
- a
GitClient
for git operations on the repository - Throws:
IOException
- if any IO failureInterruptedException
- if interrupted.
-
-