Interface GitClient
- All Known Subinterfaces:
IGitAPI
- All Known Implementing Classes:
CliGitAPIImpl,GitAPI,JGitAPIImpl
Since 1.1, this interface is remotable, meaning it can be referenced from a remote closure call.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumLevel of git configuration that will be adjusted by configuration changes. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.cloudbees.plugins.credentials.CredentialsMatcherThe supported credential types.static final booleanConstantquietRemoteBranches=Boolean.getBoolean(GitClient.class.getName() + ".quietRemoteBranches")static final booleanConstantverbose=Boolean.getBoolean(IGitAPI.class.getName() + ".verbose") -
Method Summary
Modifier and TypeMethodDescriptionvoidadd.voidaddCredentials(String url, com.cloudbees.plugins.credentials.common.StandardCredentials credentials) Adds credentials to be used against a specific url.voidaddDefaultCredentials(com.cloudbees.plugins.credentials.common.StandardCredentials credentials) Adds credentials to be used when there are not url specific credentials defined.voidAdds a new git-note on the current HEAD commit.voidaddRemoteUrl(String name, String url) addRemoteUrl.voidaddSubmodule(String remoteURL, String subdir) Create a submodule in subdir child directory for remote repositoryvoidappendNote(String note, String namespace) Appends to an existing git-note on the current HEAD commit.voidbranch.Returns aChangelogCommandto build up the git-log invocation.voidchangelog(String revFrom, String revTo, OutputStream os) Deprecated.voidAdds the changelog entries for commits in the range revFrom..revTo.checkout()checkout.voidDeprecated.usecheckout()andCheckoutCommandvoidDeprecated.usecheckout()andCheckoutCommandvoidcheckoutBranch(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 refHEADpoints to branch.voidclean()Fully revert working copy to a clean state, i.e.voidclean(boolean cleanSubmodule) Fully revert working copy to a clean state, i.e.voidRemove all credentials from the client.voidClone a remote repositoryclone_()Returns aCloneCommandto build up the git-log invocation.voidcommit.voidcommit(String message, org.eclipse.jgit.lib.PersonIdent author, org.eclipse.jgit.lib.PersonIdent committer) Deprecated.voidconfig(GitClient.ConfigLevel configLevel, String key, String value) Execute git config at the specified configuration level.voiddeleteBranch(String name) (force) delete a branch.voidDeletes a ref.voiddeleteTag.Equivalent of "git-describe --tags".voidDeprecated.usefetch_()and configure aFetchCommandvoidDeprecated.usefetch_()and configure aFetchCommandvoidDeprecated.usefetch_()and configure aFetchCommandfetch_()fetch_.getBranches.getBranchesContaining(String revspec, boolean allBranches) Find all the branches that include the given commit.getHeadRev(String url) getHeadRev.org.eclipse.jgit.lib.ObjectIdgetHeadRev(String remoteRepoUrl, String branch) getHeadRev.getRefNames(String refPrefix) List refs with the given prefix.getRemoteBranches.getRemoteReferences(String remoteRepoUrl, String pattern, boolean headsOnly, boolean tagsOnly) List references in a remote repository.getRemoteSymbolicReferences(String remoteRepoUrl, String pattern) List symbolic references in a remote repository.getRemoteTagNames(String tagPattern) getRemoteTagNames.getRemoteUrl(String name) From a given repository, get a remote's URLorg.eclipse.jgit.lib.RepositoryDeprecated.as of 1.1 This method was deprecated to makeGitClientremotable.getSubmodules(String treeIsh) Finds all the submodule references in this repository at the specified tree.getTagMessage(String tagName) getTagMessage.getTagNames(String tagPattern) getTagNames.getTags()Return name and object ID of all tags in current repository.The working tree of this repository.booleanReturns true if the repository has Git submodules.booleanReturn true if the current workspace has a git repository.booleanhasGitRepo(boolean checkParentDirectories) Return true if the current workspace has a git repository.voidinit()init.init_()init_.booleanisCommitInRepo(org.eclipse.jgit.lib.ObjectId commit) isCommitInRepo.booleanmaintenance(String task) Executes git maintenance commands based on the git version.merge()merge.voidmerge(org.eclipse.jgit.lib.ObjectId rev) Deprecated.usemerge()and configure aMergeCommandvoidprune(org.eclipse.jgit.transport.RemoteConfig repository) Prune stale remote tracking branches with "git remote prune" on the specified remote.push()push.voidDeprecated.usepush()and configure aPushCommandvoidDeprecated.usepush()and configure aPushCommandrebase()rebase.voidCreate (or update) a ref.booleanCheck if a ref exists.List<org.eclipse.jgit.lib.ObjectId>revList.revList_()revList_.List<org.eclipse.jgit.lib.ObjectId>revListAll.org.eclipse.jgit.lib.ObjectIdRetrieve commit object that is direct child forrevNamerevision reference.voidSets the identity of the author for future commits and merge operations.voidsetAuthor(org.eclipse.jgit.lib.PersonIdent p) setAuthor.voidsetCommitter(String name, String email) Sets the identity of the committer for future commits and merge operations.voidsetCommitter(org.eclipse.jgit.lib.PersonIdent p) setCommitter.voidsetCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials cred) setCredentials.voidsetProxy(ProxyConfiguration proxy) setProxy.voidsetRemoteUrl(String name, String url) For a given repository, set a remote's URLvoidsetupSubmoduleUrls(Revision rev, TaskListener listener) Set up submodule URLs so that they correspond to the remote pertaining to the revision that has been checked out.showRevision(org.eclipse.jgit.lib.ObjectId r) Given a Revision, show it as if it were an entry from git log --raw, so that it can be parsed by GitChangeLogParser.showRevision(org.eclipse.jgit.lib.ObjectId from, org.eclipse.jgit.lib.ObjectId to) Given a Revision, show it as if it were an entry from git log --raw, so that it can be parsed by GitChangeLogParser.showRevision(org.eclipse.jgit.lib.ObjectId from, org.eclipse.jgit.lib.ObjectId to, Boolean useRawOutput) Given a Revision, show it as if it were an entry fromgit log --raw, so that it can be parsed by GitChangeLogParser.subGit.voidsubmoduleClean(boolean recursive) submoduleClean.voidsubmoduleInit.submoduleUpdate.voidsubmoduleUpdate(boolean recursive) Deprecated.voidsubmoduleUpdate(boolean recursive, boolean remoteTracking) Deprecated.voidsubmoduleUpdate(boolean recursive, boolean remoteTracking, String reference) Deprecated.voidsubmoduleUpdate(boolean recursive, String reference) Deprecated.voidCreate (or update) a tag.booleantagExists.<T> TwithRepository(RepositoryCallback<T> callable) Runs the computation that requires local access toRepository.
-
Field Details
-
verbose
static final boolean verboseConstantverbose=Boolean.getBoolean(IGitAPI.class.getName() + ".verbose") -
quietRemoteBranches
static final boolean quietRemoteBranchesConstantquietRemoteBranches=Boolean.getBoolean(GitClient.class.getName() + ".quietRemoteBranches") -
CREDENTIALS_MATCHER
static final com.cloudbees.plugins.credentials.CredentialsMatcher CREDENTIALS_MATCHERThe supported credential types.- Since:
- 1.2.0
-
-
Method Details
-
clearCredentials
void clearCredentials()Remove all credentials from the client.- Since:
- 1.2.0
-
addCredentials
void addCredentials(String url, com.cloudbees.plugins.credentials.common.StandardCredentials credentials) Adds credentials to be used against a specific url.- Parameters:
url- the url for the credentials to be used against.credentials- the credentials to use.- Since:
- 1.2.0
-
addDefaultCredentials
void addDefaultCredentials(com.cloudbees.plugins.credentials.common.StandardCredentials credentials) Adds credentials to be used when there are not url specific credentials defined.- Parameters:
credentials- the credentials to use.- Since:
- 1.2.0
- See Also:
-
setAuthor
Sets the identity of the author for future commits and merge operations.- Parameters:
name- aStringobject.email- aStringobject.- Throws:
GitException- if underlying git operation fails.
-
setAuthor
setAuthor.- Parameters:
p- aPersonIdentobject.- Throws:
GitException- if underlying git operation fails.
-
setCommitter
Sets the identity of the committer for future commits and merge operations.- Parameters:
name- aStringobject.email- aStringobject.- Throws:
GitException- if underlying git operation fails.
-
setCommitter
setCommitter.- Parameters:
p- aPersonIdentobject.- Throws:
GitException- if underlying git operation fails.
-
getRepository
Deprecated.as of 1.1 This method was deprecated to makeGitClientremotable. When called on a proxy object, this method throwsNotSerializableException. UsewithRepository(RepositoryCallback)to pass in the closure instead. This prevents the repository leak (JENKINS-12188), too.Expose the JGit repository this GitClient is using. Don't forget to callRepository.close(), to avoid JENKINS-12188.- Returns:
- a
Repositoryobject. - Throws:
GitException- if underlying git operation fails.
-
withRepository
<T> T withRepository(RepositoryCallback<T> callable) throws GitException, IOException, InterruptedException Runs the computation that requires local access toRepository.- Type Parameters:
T- type for the repository callback- Parameters:
callable- the repository callback used as closure to instance- Returns:
- a T object.
- Throws:
IOException- in case of IO errorInterruptedException- if interruptedGitException
-
getWorkTree
FilePath getWorkTree()The working tree of this repository.- Returns:
- a
FilePathobject.
-
init
init.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
add
add.- Parameters:
filePattern- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
commit
commit.- Parameters:
message- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
commit
@Deprecated void commit(String message, org.eclipse.jgit.lib.PersonIdent author, org.eclipse.jgit.lib.PersonIdent committer) throws GitException, InterruptedException Deprecated.commit.- Parameters:
message- aStringobject.author- aPersonIdentobject.committer- aPersonIdentobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
hasGitRepo
Return true if the current workspace has a git repository.- Returns:
- true if this workspace has a git repository
- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
hasGitRepo
Return true if the current workspace has a git repository. If checkParentDirectories is true, searches parent directories. If checkParentDirectories is false, checks workspace directory only.- Parameters:
checkParentDirectories- if true, search upward for a git repository- Returns:
- true if this workspace has a git repository
- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
isCommitInRepo
boolean isCommitInRepo(org.eclipse.jgit.lib.ObjectId commit) throws GitException, InterruptedException isCommitInRepo.- Parameters:
commit- aObjectIdobject.- Returns:
- true if commit is in repository
- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
getRemoteUrl
From a given repository, get a remote's URL- Parameters:
name- The name of the remote (e.g. origin)- Returns:
- a
Stringobject. - Throws:
GitException- if executing the git command failsInterruptedException- if interrupted.
-
setRemoteUrl
For a given repository, set a remote's URL- Parameters:
name- The name of the remote (e.g. origin)url- The new value of the remote's URL- Throws:
GitException- if executing the git command failsInterruptedException- if interrupted.
-
addRemoteUrl
addRemoteUrl.- Parameters:
name- aStringobject.url- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
checkout
Deprecated.usecheckout()andCheckoutCommandChecks out the specified commit/tag/branch into the workspace. (equivalent ofgit checkout branch.)- Parameters:
ref- A git object references expression (either a sha1, tag or branch)- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
checkout
Deprecated.usecheckout()andCheckoutCommandCreates a new branch that points to the specified ref. (equivalent to git checkout -b branch commit) This will fail if the branch already exists.- Parameters:
ref- A git object references expression. For backward compatibility,nullwill checkout current HEADbranch- name of the branch to create from reference- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
checkout
CheckoutCommand checkout()checkout.- Returns:
- a
CheckoutCommandobject.
-
checkoutBranch
void checkoutBranch(@CheckForNull String branch, String ref) throws GitException, InterruptedException 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
HEADpoints to branch. In other words, the workspace is on the specified branch.- Both index and workspace are the same tree with ref. (no dirty files and no staged changes, although this method will not touch untracked files in the workspace.)
This method is preferred over the
checkout(String, String)family of methods, as this method is affected far less by the current state of the repository. Thecheckoutmethods, 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
checkout(String, String).- Parameters:
branch- aStringobject.ref- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.- Since:
- 1.0.6
-
clone
void clone(String url, String origin, boolean useShallowClone, String reference) throws GitException, InterruptedException Clone a remote repository- Parameters:
url- URL for remote repository to cloneorigin- upstream track name, defaults tooriginby 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)- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
clone_
CloneCommand clone_()Returns aCloneCommandto build up the git-log invocation.- Returns:
- a
CloneCommandobject.
-
fetch
@Deprecated void fetch(org.eclipse.jgit.transport.URIish url, List<org.eclipse.jgit.transport.RefSpec> refspecs) throws GitException, InterruptedException Deprecated.usefetch_()and configure aFetchCommandFetch commits from url which match any of the passed in refspecs. Assumesremote.remoteName.urlhas been set.- Parameters:
url- aURIishobject.refspecs- aListobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
fetch
@Deprecated void fetch(String remoteName, org.eclipse.jgit.transport.RefSpec... refspec) throws GitException, InterruptedException Deprecated.usefetch_()and configure aFetchCommandfetch.- Parameters:
remoteName- aStringobject.refspec- aRefSpecobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
fetch
@Deprecated void fetch(String remoteName, org.eclipse.jgit.transport.RefSpec refspec) throws GitException, InterruptedException Deprecated.usefetch_()and configure aFetchCommandfetch.- Parameters:
remoteName- aStringobject.refspec- aRefSpecobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
fetch_
FetchCommand fetch_()fetch_.- Returns:
- a
FetchCommandobject.
-
push
Deprecated.usepush()and configure aPushCommandpush.- Parameters:
remoteName- aStringobject.refspec- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
push
@Deprecated void push(org.eclipse.jgit.transport.URIish url, String refspec) throws GitException, InterruptedException Deprecated.usepush()and configure aPushCommandpush.- Parameters:
url- aURIishobject.refspec- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
push
PushCommand push()push.- Returns:
- a
PushCommandobject.
-
merge
Deprecated.usemerge()and configure aMergeCommandmerge.- Parameters:
rev- aObjectIdobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
merge
MergeCommand merge()merge.- Returns:
- a
MergeCommandobject.
-
rebase
RebaseCommand rebase()rebase.- Returns:
- a
RebaseCommandobject.
-
init_
InitCommand init_()init_.- Returns:
- a
InitCommandobject.
-
prune
void prune(org.eclipse.jgit.transport.RemoteConfig repository) throws GitException, InterruptedException Prune stale remote tracking branches with "git remote prune" on the specified remote.- Parameters:
repository- aRemoteConfigobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
clean
Fully revert working copy to a clean state, i.e. run both git-reset(1) --hard then git-clean(1) for working copy to match a fresh clone.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
clean
Fully revert working copy to a clean state, i.e. run both git-reset(1) --hard then git-clean(1) for working copy to match a fresh clone.- Parameters:
cleanSubmodule- flag to add extra -f- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
branch
branch.- Parameters:
name- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
deleteBranch
(force) delete a branch.- Parameters:
name- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
getBranches
getBranches.- Returns:
- a
Setobject. - Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
getRemoteBranches
getRemoteBranches.- Returns:
- a
Setobject. - Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
tag
Create (or update) a tag. If tag already exist it gets updated (equivalent togit tag --force)- Parameters:
tagName- aStringobject.comment- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
tagExists
tagExists.- Parameters:
tagName- aStringobject.- Returns:
- true if tag exists in repository
- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
getTagMessage
getTagMessage.- Parameters:
tagName- aStringobject.- Returns:
- a
Stringobject. - Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
deleteTag
deleteTag.- Parameters:
tagName- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
getTagNames
getTagNames.- Parameters:
tagPattern- aStringobject.- Returns:
- a
Setobject. - Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
getRemoteTagNames
getRemoteTagNames.- Parameters:
tagPattern- aStringobject.- Returns:
- a
Setobject. - Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
ref
Create (or update) a ref. The ref will reference HEAD (equivalent togit update-ref ... HEAD).- Parameters:
refName- the full name of the ref (e.g. "refs/myref"). Spaces will be replaced with underscores.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
refExists
Check if a ref exists. Equivalent to comparing the return code ofgit show-refto zero.- Parameters:
refName- the full name of the ref (e.g. "refs/myref"). Spaces will be replaced with underscores.- Returns:
- True if the ref exists, false otherwise.
- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
deleteRef
Deletes a ref. Has no effect if the ref does not exist, equivalent togit update-ref -d.- Parameters:
refName- the full name of the ref (e.g. "refs/myref"). Spaces will be replaced with underscores.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
getRefNames
List refs with the given prefix. Equivalent togit for-each-ref --format="%(refname)".- Parameters:
refPrefix- the literal prefix any ref returned will have. The empty string implies all.- Returns:
- a set of refs, each beginning with the given prefix. Empty if none.
- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
getHeadRev
Map<String,org.eclipse.jgit.lib.ObjectId> getHeadRev(String url) throws GitException, InterruptedException getHeadRev.- Parameters:
url- aStringobject.- Returns:
- a
Mapobject. - Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
getHeadRev
org.eclipse.jgit.lib.ObjectId getHeadRev(String remoteRepoUrl, String branch) throws GitException, InterruptedException getHeadRev.- Parameters:
remoteRepoUrl- aStringobject.branch- aStringobject.- Returns:
- a
ObjectIdobject. - Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
getRemoteReferences
Map<String,org.eclipse.jgit.lib.ObjectId> getRemoteReferences(String remoteRepoUrl, String pattern, boolean headsOnly, boolean tagsOnly) throws GitException, InterruptedException List references in a remote repository. Equivalent togit ls-remote [--heads] [--tags] <repository> [<refs>].- Parameters:
remoteRepoUrl- Remote repository URL.pattern- Only references matching the given pattern are displayed.headsOnly- Limit to only refs/heads.tagsOnly- Limit to only refs/tags. headsOnly and tagsOnly are not mutually exclusive; when both are true, references stored in refs/heads and refs/tags are displayed.- Returns:
- a map of reference names and their commit hashes. Empty if none.
- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
getRemoteSymbolicReferences
Map<String,String> getRemoteSymbolicReferences(String remoteRepoUrl, String pattern) throws GitException, InterruptedException List symbolic references in a remote repository. Equivalent togit ls-remote --symref <repository> [<refs>]. Note: the response may be empty for multiple reasons- Parameters:
remoteRepoUrl- Remote repository URL.pattern- Only references matching the given pattern are displayed.- Returns:
- a map of reference names and their underlying references. Empty if none or if the remote does not report symbolic references or if the command line git version does not support reporting symbolic references.
- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
revParse
Retrieve commit object that is direct child forrevNamerevision reference.- Parameters:
revName- a commit sha1 or tag/branch refname- Returns:
- a
ObjectIdobject. - Throws:
GitException- when no such commit / revName is found in repository.InterruptedException- if interrupted.
-
revList_
RevListCommand revList_()revList_.- Returns:
- a
RevListCommandobject.
-
revListAll
revListAll.- Returns:
- a
Listobject. - Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
revList
revList.- Parameters:
ref- aStringobject.- Returns:
- a
Listobject. - Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
subGit
subGit.- Parameters:
subdir- aStringobject.- Returns:
- a IGitAPI implementation to manage git submodule repository
-
hasGitModules
Returns true if the repository has Git submodules.- Returns:
- true if this repository has submodules
- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
getSubmodules
Finds all the submodule references in this repository at the specified tree.- Parameters:
treeIsh- aStringobject.- Returns:
- never null.
- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
addSubmodule
Create a submodule in subdir child directory for remote repository- Parameters:
remoteURL- aStringobject.subdir- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
submoduleUpdate
Deprecated.Run submodule update optionally recursively on all submodules (equivalent ofgit submodule update --recursive.)- Parameters:
recursive- a boolean.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
submoduleUpdate
@Deprecated void submoduleUpdate(boolean recursive, String reference) throws GitException, InterruptedException Deprecated.Run submodule update optionally recursively on all submodules, with a specific reference passed to git clone if needing to --init. (equivalent ofgit submodule update --recursive --reference 'reference'.)- Parameters:
recursive- a boolean.reference- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
submoduleUpdate
@Deprecated void submoduleUpdate(boolean recursive, boolean remoteTracking) throws GitException, InterruptedException Deprecated.Run submodule update optionally recursively on all submodules, optionally with remoteTracking submodules (equivalent ofgit submodule update --recursive --remote.)- Parameters:
recursive- a boolean.remoteTracking- a boolean.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
submoduleUpdate
@Deprecated void submoduleUpdate(boolean recursive, boolean remoteTracking, String reference) throws GitException, InterruptedException Deprecated.Run submodule update optionally recursively on all submodules, optionally with remoteTracking, with a specific reference passed to git clone if needing to --init. (equivalent ofgit submodule update --recursive --remote --reference 'reference'.)- Parameters:
recursive- a boolean.remoteTracking- a boolean.reference- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
submoduleUpdate
SubmoduleUpdateCommand submoduleUpdate()submoduleUpdate.- Returns:
- a
SubmoduleUpdateCommandobject.
-
submoduleClean
submoduleClean.- Parameters:
recursive- a boolean.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
submoduleInit
submoduleInit.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
setupSubmoduleUrls
void setupSubmoduleUrls(Revision rev, TaskListener listener) throws GitException, InterruptedException Set up submodule URLs so that they correspond to the remote pertaining to the revision that has been checked out.- Parameters:
rev- aRevisionobject.listener- aTaskListenerobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
changelog
@Deprecated void changelog(String revFrom, String revTo, OutputStream os) throws GitException, InterruptedException Deprecated.changelog.- Parameters:
revFrom- aStringobject.revTo- aStringobject.os- aOutputStreamobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
changelog
Adds the changelog entries for commits in the range revFrom..revTo. This is just a short cut for callingchangelog()with appropriate parameters.- Parameters:
revFrom- aStringobject.revTo- aStringobject.os- aWriterobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
changelog
Returns aChangelogCommandto build up the git-log invocation.- Returns:
- a
ChangelogCommandobject. - Throws:
GitException
-
appendNote
Appends to an existing git-note on the current HEAD commit. If a note doesn't exist, it works just likeaddNote(String, String)- Parameters:
note- Content of the note.namespace- If unqualified, interpreted as "refs/notes/NAMESPACE" just like cgit.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
addNote
Adds a new git-note on the current HEAD commit.- Parameters:
note- Content of the note.namespace- If unqualified, interpreted as "refs/notes/NAMESPACE" just like cgit.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
showRevision
List<String> showRevision(org.eclipse.jgit.lib.ObjectId r) throws GitException, InterruptedException Given a Revision, show it as if it were an entry from git log --raw, so that it can be parsed by GitChangeLogParser.Changes are computed on the [from..to] range. If
fromis null, this prints just one commit thattorepresents.For merge commit, this method reports one diff per each parent. This makes this method behave differently from
changelog().- Parameters:
r- aObjectIdobject.- Returns:
- The git log output, in
rawformat. - Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
showRevision
List<String> showRevision(org.eclipse.jgit.lib.ObjectId from, org.eclipse.jgit.lib.ObjectId to) throws GitException, InterruptedException Given a Revision, show it as if it were an entry from git log --raw, so that it can be parsed by GitChangeLogParser.Changes are computed on the [from..to] range. If
fromis null, this prints just one commit thattorepresents.For merge commit, this method reports one diff per each parent. This makes this method behave differently from
changelog().- Parameters:
from- aObjectIdobject.to- aObjectIdobject.- Returns:
- The git log output, in
rawformat. - Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
showRevision
List<String> showRevision(org.eclipse.jgit.lib.ObjectId from, org.eclipse.jgit.lib.ObjectId to, Boolean useRawOutput) throws GitException, InterruptedException Given a Revision, show it as if it were an entry fromgit log --raw, so that it can be parsed by GitChangeLogParser.If useRawOutput is true, the '--raw' option will include commit file information to be passed to the GitChangeLogParser.
Changes are computed on the [from..to] range. If
fromis null, this prints just one commit thattorepresents.For merge commit, this method reports one diff per each parent. This makes this method behave differently from
changelog().- Parameters:
from- aObjectIdobject.to- aObjectIdobject.useRawOutput- a {java.lang.Boolean} object.- Returns:
- The git log output, in
rawformat. - Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
describe
Equivalent of "git-describe --tags". Find a nearby tag (including unannotated ones) and come up with a short identifier to describe the tag.- Parameters:
commitIsh- aStringobject.- Returns:
- a
Stringobject. - Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
setCredentials
void setCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials cred) setCredentials.- Parameters:
cred- aStandardUsernameCredentialsobject.
-
setProxy
setProxy.- Parameters:
proxy- aProxyConfigurationobject.
-
getBranchesContaining
List<Branch> getBranchesContaining(String revspec, boolean allBranches) throws GitException, InterruptedException Find all the branches that include the given commit.- Parameters:
revspec- commit id to query forallBranches- whether remote branches should be also queried (true) or not (false)- Returns:
- list of branches the specified commit belongs to
- Throws:
GitException- on Git exceptionsInterruptedException- on thread interruption
-
getTags
Return name and object ID of all tags in current repository.- Returns:
- set of tags in current repository
- Throws:
GitException- on Git exceptionsInterruptedException- on thread interruption
-
maintenance
Executes git maintenance commands based on the git version.- Parameters:
task- aStringobject. i.e (prefetch/gc/commit-graph/incremental-repack/loose-objects)- Returns:
- Boolean if maintenance has been executed or not.
- Throws:
InterruptedException- if underlying git operation fails.
-
config
void config(GitClient.ConfigLevel configLevel, String key, String value) throws GitException, InterruptedException Execute git config at the specified configuration level. If value is null, the key will be removed from the configuration.- Parameters:
configLevel- configuration level that will be modified. If null, thenGitClient.ConfigLevel.LOCALwill be used.key- configuration section expressed assection[.subsection].namevalue- configuration value. If null, the key will be removed from the configuration (unset)- Throws:
GitException- on Git exceptionInterruptedException- on thread interruption
-
changelog(String, String, Writer)