@Deprecated public class GitAPI extends CliGitAPIImpl
Git.USE_CLI).
New implementations should use GitClient.| Modifier and Type | Field and Description |
|---|---|
protected hudson.ProxyConfiguration |
proxy |
protected File |
workspace |
TIMEOUT, USE_SETSIDCREDENTIALS_MATCHER, quietRemoteBranches, verbose| Constructor and Description |
|---|
GitAPI(String gitExe,
hudson.FilePath repository,
hudson.model.TaskListener listener,
hudson.EnvVars environment)
Deprecated.
|
GitAPI(String gitExe,
hudson.FilePath repository,
hudson.model.TaskListener listener,
hudson.EnvVars environment,
String reference)
Deprecated.
|
GitAPI(String gitExe,
File repository,
hudson.model.TaskListener listener,
hudson.EnvVars environment)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(String filePattern)
Deprecated.
add.
|
void |
branch(String name)
Deprecated.
branch.
|
void |
changelog(String revFrom,
String revTo,
OutputStream outputStream)
changelog.
|
void |
changelog(String revFrom,
String revTo,
Writer w)
Adds the changelog entries for commits in the range revFrom..revTo.
|
void |
checkout(String ref)
Deprecated.
Checks out the specified commit/tag/branch into the workspace.
|
void |
checkout(String ref,
String branch)
Deprecated.
Creates a new branch that points to the specified ref.
|
void |
checkoutBranch(String branch,
String ref)
Regardless of the current state of the workspace (whether there is some dirty files, etc)
and the state of the repository (whether the branch of the specified name exists or not),
when this method exits the following conditions hold:
The branch of the specified name branch exists and points to the specified ref
HEAD points to branch. |
void |
clean()
Deprecated.
Remove untracked files and directories, including files listed
in the ignore rules.
|
void |
clone(RemoteConfig source)
Deprecated.
|
void |
clone(RemoteConfig rc,
boolean useShallowClone)
Deprecated.
|
void |
clone(String url,
String origin,
boolean useShallowClone,
String reference)
Clone a remote repository
|
void |
commit(String message)
Deprecated.
commit.
|
void |
commit(String message,
PersonIdent author,
PersonIdent committer)
Deprecated.
commit.
|
void |
deleteBranch(String name)
Deprecated.
(force) delete a branch.
|
void |
deleteTag(String tagName)
Deprecated.
deleteTag.
|
protected String |
extractBranchNameFromBranchSpec(String branchSpec)
This method takes a branch specification and normalizes it get unambiguous results.
|
void |
fetch()
Deprecated.
|
void |
fetch(RemoteConfig remoteRepository)
Deprecated.
|
void |
fetch(String remoteName,
RefSpec... refspec)
Deprecated.
fetch.
|
void |
fetch(String remoteName,
RefSpec refspec)
Deprecated.
fetch.
|
void |
fetch(String repository,
String refspec)
Deprecated.
|
void |
fetch(URIish url,
List<RefSpec> refspecs)
Deprecated.
Fetch commits from url which match any of the passed in
refspecs.
|
Set<Branch> |
getBranches()
Deprecated.
Returns the set of branches defined in this repository,
including local branches and remote branches.
|
Set<Branch> |
getRemoteBranches()
Deprecated.
Returns the remote branches defined in this repository.
|
String |
getRemoteUrl(String name)
Deprecated.
From a given repository, get a remote's URL
|
Repository |
getRepository()
Deprecated.
Returns the
Repository used by this git instance. |
String |
getTagMessage(String tagName)
Deprecated.
getTagMessage.
|
List<Tag> |
getTagsOnCommit(String revName)
Deprecated.
|
boolean |
hasGitModules()
hasGitModules.
|
boolean |
hasGitModules(String treeIsh)
Deprecated.
|
boolean |
hasGitRepo()
Deprecated.
hasGitRepo.
|
void |
init()
Deprecated.
Initialize an empty repository for further git operations.
|
boolean |
isBareRepository()
isBareRepository.
|
boolean |
isCommitInRepo(ObjectId commit)
Deprecated.
isCommitInRepo.
|
List<IndexEntry> |
lsTree(String treeIsh)
This method has been implemented as non-recursive historically, but
often that is not what the caller wants.
|
void |
merge(ObjectId rev)
merge.
|
void |
push(String remoteName,
String refspec)
Deprecated.
push.
|
void |
push(URIish url,
String refspec)
Deprecated.
|
protected org.jenkinsci.plugins.gitclient.RemoteGitImpl |
remoteProxyFor(GitClient proxy)
remoteProxyFor.
|
void |
reset()
Deprecated.
|
List<ObjectId> |
revListBranch(String branchId)
Deprecated.
|
ObjectId |
revParse(String revName)
Deprecated.
Retrieve commit object that is direct child for
revName revision reference. |
void |
setAuthor(PersonIdent p)
setAuthor.
|
void |
setCommitter(PersonIdent p)
setCommitter.
|
void |
setCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials cred)
setCredentials.
|
void |
setProxy(hudson.ProxyConfiguration proxy)
setProxy.
|
void |
setRemoteUrl(String name,
String url)
Deprecated.
For a given repository, set a remote's URL
|
void |
setupSubmoduleUrls(String remote,
hudson.model.TaskListener listener)
Deprecated.
|
List<String> |
showRevision(ObjectId r)
Given a Revision, show it as if it were an entry from git whatchanged, so that it
can be parsed by GitChangeLogParser.
|
List<String> |
showRevision(Revision r)
Deprecated.
|
GitClient |
subGit(String subdir)
Deprecated.
subGit.
|
void |
submoduleUpdate(boolean recursive)
Run submodule update optionally recursively on all submodules
(equivalent of
git submodule update --recursive.) |
void |
submoduleUpdate(boolean recursive,
boolean remoteTracking)
Run submodule update optionally recursively on all submodules, optionally with remoteTracking submodules
(equivalent of
git submodule update --recursive --remote.) |
void |
submoduleUpdate(boolean recursive,
boolean remoteTracking,
String reference)
Run submodule update optionally recursively on all submodules, optionally with remoteTracking, with a specific
reference passed to git clone if needing to --init.
|
void |
submoduleUpdate(boolean recursive,
String reference)
Run submodule update optionally recursively on all submodules, with a specific
reference passed to git clone if needing to --init.
|
void |
tag(String tagName,
String comment)
Deprecated.
Create (or update) a tag.
|
boolean |
tagExists(String tagName)
Deprecated.
tagExists.
|
<T> T |
withRepository(RepositoryCallback<T> callable)
Runs the computation that requires local access to
Repository. |
protected Object |
writeReplace()
When sent to remote, switch to the proxy.
|
addCredentials, addDefaultCredentials, addNote, addRemoteUrl, addSubmodule, appendNote, changelog, checkout, clean, clearCredentials, clone_, deleteRef, describe, fetch_, fixSubmoduleUrls, getAllLogEntries, getBranchesContaining, getBranchesContaining, getDefaultRemote, getDefaultRemote, getHeadRev, getHeadRev, getRefNames, getRemoteReferences, getRemoteSymbolicReferences, getRemoteTagNames, getRemoteUrl, getSubmodulePath, getSubmodules, getSubmoduleUrl, getTagNames, getTags, getWorkTree, hasGitRepo, init_, isBareRepository, isShallowRepository, launchCommand, launchCommand, lsTree, merge, merge, mergeBase, prune, push, push, rebase, ref, refExists, reset, revList_, revList, revListAll, setAuthor, setCommitter, setRemoteUrl, setSubmoduleUrl, setupSubmoduleUrls, showRevision, showRevision, submoduleClean, submoduleInit, submoduleReset, submoduleSync, submoduleUpdate, validateRevisionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitchangelog, checkoutBranchchangelog, clone, merge, setAuthor, setCommitter, setCredentials, setProxy, submoduleUpdate, submoduleUpdate, submoduleUpdate, submoduleUpdate, withRepositoryprotected final File workspace
protected hudson.ProxyConfiguration proxy
@Deprecated public GitAPI(String gitExe, hudson.FilePath repository, hudson.model.TaskListener listener, hudson.EnvVars environment) throws IOException, InterruptedException
gitExe - name of git executable (git or git.exe or jgit)repository - a FilePath for the repository directorylistener - a TaskListener which monitors the git workenvironment - the EnvVars environment for the buildIOException - if any IO failureInterruptedException - if interrupted@Deprecated public GitAPI(String gitExe, hudson.FilePath repository, hudson.model.TaskListener listener, hudson.EnvVars environment, String reference) throws IOException, InterruptedException
gitExe - name of git executable (git or git.exe or jgit)repository - a FilePath for the repository directorylistener - a TaskListener which monitors the git workenvironment - the EnvVars environment for the buildreference - SHA1 for checkoutIOException - if any IO failureInterruptedException - if interrupted.@Deprecated public GitAPI(String gitExe, File repository, hudson.model.TaskListener listener, hudson.EnvVars environment) throws IOException, InterruptedException
gitExe - name of git executable (git or git.exe or jgit)repository - a FilePath for the repository directorylistener - a TaskListener which monitors the git workenvironment - the EnvVars environment for the buildIOException - if any IO failureInterruptedException - if interrupted.public void add(String filePattern) throws GitException, InterruptedException
add in interface GitClientadd in class CliGitAPIImplfilePattern - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public String getRemoteUrl(String name) throws GitException, InterruptedException
getRemoteUrl in interface GitClientgetRemoteUrl in class CliGitAPIImplname - The name of the remote (e.g. origin)String object.GitException - if executing the git command failsInterruptedException - if interrupted.public void push(String remoteName, String refspec) throws GitException, InterruptedException
push in interface GitClientremoteName - a String object.refspec - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public String getTagMessage(String tagName) throws GitException, InterruptedException
getTagMessage in interface GitClientgetTagMessage in class CliGitAPIImpltagName - a String object.String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public GitClient subGit(String subdir)
subGit in interface GitClientsubGit in class CliGitAPIImplsubdir - a String object.public void setRemoteUrl(String name, String url) throws GitException, InterruptedException
setRemoteUrl in interface GitClientsetRemoteUrl in class CliGitAPIImplname - The name of the remote (e.g. origin)url - The new value of the remote's URLGitException - if executing the git command failsInterruptedException - if interrupted.public Set<Branch> getBranches() throws GitException, InterruptedException
getBranches in interface GitClientgetBranches in class CliGitAPIImplSet object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public Set<Branch> getRemoteBranches() throws GitException, InterruptedException
getRemoteBranches in interface GitClientgetRemoteBranches in class CliGitAPIImplSet of remote branches in this repositoryGitException - if underlying git operation fails.InterruptedException - if interrupted.public void init()
throws GitException,
InterruptedException
init in interface GitClientinit in class CliGitAPIImplGitException - if underlying git operation fails.InterruptedException - if interrupted.public void deleteBranch(String name) throws GitException, InterruptedException
deleteBranch in interface GitClientdeleteBranch in class CliGitAPIImplname - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void checkout(String ref, String branch) throws GitException, InterruptedException
checkout in interface GitClientref - A git object references expression. For backward compatibility, null will checkout current HEADbranch - name of the branch to create from referenceGitException - if underlying git operation fails.InterruptedException - if interrupted.public boolean hasGitRepo()
throws GitException,
InterruptedException
hasGitRepo in interface GitClienthasGitRepo in class CliGitAPIImplGitException - if underlying git operation fails.InterruptedException - if interrupted.public boolean isCommitInRepo(ObjectId commit) throws GitException, InterruptedException
isCommitInRepo in interface GitClientisCommitInRepo in class CliGitAPIImplcommit - a ObjectId object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void commit(String message) throws GitException, InterruptedException
commit in interface GitClientcommit in class CliGitAPIImplmessage - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void commit(String message, PersonIdent author, PersonIdent committer) throws GitException, InterruptedException
commit in interface GitClientmessage - a String object.author - a PersonIdent object.committer - a PersonIdent object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void checkout(String ref) throws GitException, InterruptedException
git checkout branch.)checkout in interface GitClientref - A git object references expression (either a sha1, tag or branch)GitException - if underlying git operation fails.InterruptedException - if interrupted.public void deleteTag(String tagName) throws GitException, InterruptedException
deleteTag in interface GitClientdeleteTag in class CliGitAPIImpltagName - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.@NonNull public Repository getRepository() throws GitException
Repository used by this git instance.getRepository in interface GitClientgetRepository in class CliGitAPIImplRepository object.GitException - if underlying git operation fails.public void tag(String tagName, String comment) throws GitException, InterruptedException
git tag --force)tag in interface GitClienttag in class CliGitAPIImpltagName - a String object.comment - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void fetch(URIish url, List<RefSpec> refspecs) throws GitException, InterruptedException
remote.remoteName.url has been set.fetch in interface GitClientfetch in class CliGitAPIImplurl - a URIish object.refspecs - a List object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void fetch(String remoteName, RefSpec... refspec) throws GitException, InterruptedException
fetch in interface GitClientfetch in class CliGitAPIImplremoteName - a String object.refspec - a RefSpec object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void fetch(String remoteName, RefSpec refspec) throws GitException, InterruptedException
fetch in interface GitClientfetch in class CliGitAPIImplremoteName - a String object.refspec - a RefSpec object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public boolean tagExists(String tagName) throws GitException, InterruptedException
tagExists in interface GitClienttagExists in class CliGitAPIImpltagName - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void clean()
throws GitException,
InterruptedException
clean in interface GitClientclean in class CliGitAPIImplGitException - if underlying git operation fails.InterruptedException - if interrupted.public ObjectId revParse(String revName) throws GitException, InterruptedException
revName revision reference.revParse in interface GitClientrevParse in class CliGitAPIImplrevName - a commit sha1 or tag/branch refnameObjectId object.GitException - when no such commit / revName is found in repository.InterruptedException - if interrupted.public void branch(String name) throws GitException, InterruptedException
branch in interface GitClientbranch in class CliGitAPIImplname - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public boolean isBareRepository()
throws GitException,
InterruptedException
isBareRepository in interface IGitAPIGitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public boolean hasGitModules(String treeIsh) throws GitException
hasGitModules in interface IGitAPItreeIsh - an ignored argument, kept for compatibilityGitException - if underlying git operation fails.GitClient.hasGitModules()@Deprecated public void setupSubmoduleUrls(String remote, hudson.model.TaskListener listener) throws GitException, InterruptedException
setupSubmoduleUrls in interface IGitAPIGitExceptionInterruptedException@Deprecated public void fetch(String repository, String refspec) throws GitException, InterruptedException
fetch in interface IGitAPIrepository - URL of the repository to be retrievedrefspec - definition of mapping from remote refs to local refsGitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public void fetch(RemoteConfig remoteRepository) throws InterruptedException
fetch in interface IGitAPIremoteRepository - remote configuration from which refs will be retrievedInterruptedException - if interrupted.@Deprecated public void fetch() throws GitException, InterruptedException
fetch in interface IGitAPIGitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public void reset() throws GitException, InterruptedException
reset in interface IGitAPIGitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public void push(URIish url, String refspec) throws GitException, InterruptedException
push in interface GitClienturl - a URIish object.refspec - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public void clone(RemoteConfig source) throws GitException, InterruptedException
clone in interface IGitAPIsource - remote repository to be clonedGitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public void clone(RemoteConfig rc, boolean useShallowClone) throws GitException, InterruptedException
RemoteConfig rc to this repository.clone in interface IGitAPIrc - the remote config for the remote repositoryuseShallowClone - if true, use a shallow cloneGitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public List<ObjectId> revListBranch(String branchId) throws GitException, InterruptedException
revListBranch in interface IGitAPIbranchId - a String object.List object.GitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public List<String> showRevision(Revision r) throws GitException, InterruptedException
showRevision in interface IGitAPIr - a Revision object.List object.GitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public List<Tag> getTagsOnCommit(String revName) throws GitException, IOException
getTagsOnCommit in interface IGitAPIrevName - a String object.List object.GitException - if underlying git operation fails.IOException - if any IO failurepublic final List<IndexEntry> lsTree(String treeIsh) throws GitException, InterruptedException
lsTree in interface IGitAPItreeIsh - string representation of a treeIsh itemGitException - on failureInterruptedException - if interruptedprotected Object writeReplace() throws ObjectStreamException
Object object.ObjectStreamException - if current channel is nullpublic boolean hasGitModules()
throws GitException
hasGitModules in interface GitClientGitException - if underlying git operation fails.public List<String> showRevision(ObjectId r) throws GitException, InterruptedException
Changes are computed on the [from..to] range. If from is null, this prints
just one commit that to represents.
For merge commit, this method reports one diff per each parent. This makes this method
behave differently from GitClient.changelog().
showRevision in interface GitClientr - a ObjectId object.raw format.GitException - if underlying git operation fails.InterruptedException - if interrupted.protected String extractBranchNameFromBranchSpec(String branchSpec)
| branch spec | normalized | |
|---|---|---|
master | master* | |
feature1 | feature1* | |
feature1/master | master feature1/master* | |
origin/master | master* | |
repo2/feature1 | feature1* | |
refs/heads/feature1 | refs/heads/feature1 | |
| origin/namespaceA/fix15 | fix15 namespaceA/fix15* | |
refs/heads/namespaceA/fix15 | refs/heads/namespaceA/fix15 | |
remotes/origin/namespaceA/fix15 | refs/heads/namespaceA/fix15 |
branchSpec - a String object.public <T> T withRepository(RepositoryCallback<T> callable) throws IOException, InterruptedException
Repository.withRepository in interface GitClientT - type for the repository callbackcallable - the repository callback used as closure to instanceIOException - in case of IO errorInterruptedException - if interruptedpublic void setAuthor(PersonIdent p)
setAuthor in interface GitClientp - a PersonIdent object.public void setCommitter(PersonIdent p)
setCommitter in interface GitClientp - a PersonIdent object.public void changelog(String revFrom, String revTo, OutputStream outputStream) throws GitException, InterruptedException
changelog in interface GitClientrevFrom - a String object.revTo - a String object.outputStream - a OutputStream object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void changelog(String revFrom, String revTo, Writer w) throws GitException, InterruptedException
GitClient.changelog() with appropriate parameters.changelog in interface GitClientrevFrom - a String object.revTo - a String object.w - a Writer object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void clone(String url, String origin, boolean useShallowClone, String reference) throws GitException, InterruptedException
clone in interface GitClienturl - URL for remote repository to cloneorigin - upstream track name, defaults to origin by conventionuseShallowClone - option to create a shallow clone, that has some restriction but will make clone operationreference - (optional) reference to a local clone for faster clone operations (reduce network and local storage costs)GitException - if underlying git operation fails.InterruptedException - if interrupted.public void checkoutBranch(String branch, String ref) throws GitException, InterruptedException
HEAD points to branch. In other words, the workspace is on the specified branch.
This method is preferred over the GitClient.checkout(String, String) family of methods, as
this method is affected far less by the current state of the repository. The checkout
methods, in their attempt to emulate the "git checkout" command line behaviour, have too many
side effects. In Jenkins, where you care a lot less about throwing away local changes and
care a lot more about resetting the workspace into a known state, methods like this is more useful.
For compatibility reasons, the order of the parameter is different from GitClient.checkout(String, String).
checkoutBranch in interface GitClientbranch - a String object.ref - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void merge(ObjectId rev) throws GitException, InterruptedException
merge in interface GitClientrev - a ObjectId object.GitException - if underlying git operation fails.InterruptedException - if interrupted.protected org.jenkinsci.plugins.gitclient.RemoteGitImpl remoteProxyFor(GitClient proxy)
proxy - a GitClient object.RemoteGitImpl object.public void setCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials cred)
setCredentials in interface GitClientcred - a StandardUsernameCredentials object.public void setProxy(hudson.ProxyConfiguration proxy)
public void submoduleUpdate(boolean recursive)
throws GitException,
InterruptedException
git submodule update --recursive.)submoduleUpdate in interface GitClientrecursive - a boolean.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void submoduleUpdate(boolean recursive,
String reference)
throws GitException,
InterruptedException
git submodule update --recursive --reference 'reference'.)submoduleUpdate in interface GitClientrecursive - a boolean.reference - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void submoduleUpdate(boolean recursive,
boolean remoteTracking)
throws GitException,
InterruptedException
git submodule update --recursive --remote.)submoduleUpdate in interface GitClientrecursive - a boolean.remoteTracking - a boolean.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void submoduleUpdate(boolean recursive,
boolean remoteTracking,
String reference)
throws GitException,
InterruptedException
git submodule update --recursive --remote --reference 'reference'.)submoduleUpdate in interface GitClientrecursive - a boolean.remoteTracking - a boolean.reference - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.Copyright © 2013–2020. All rights reserved.