Class BitbucketCloudApiClient
java.lang.Object
com.cloudbees.jenkins.plugins.bitbucket.impl.client.AbstractBitbucketApi
com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient
- All Implemented Interfaces:
BitbucketApi,AutoCloseable
-
Field Summary
Fields inherited from class com.cloudbees.jenkins.plugins.bitbucket.impl.client.AbstractBitbucketApi
logger -
Constructor Summary
ConstructorsConstructorDescriptionBitbucketCloudApiClient(boolean enableCache, int teamCacheDuration, int repositoriesCacheDuration, String owner, String projectKey, String repositoryName, BitbucketAuthenticator authenticator) -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckPathExists(String branchOrHash, String path) Checks if the given path exists in the repository at the specified branch.static voidjenkins.scm.impl.avatars.AvatarImageReturns an Avatar image from the given URL.protected StringReturns a branch in the repository.Returns the branches in the repository.getBranchesByRef(String nodePath) protected org.apache.hc.client5.http.impl.classic.CloseableHttpClientgetCommits(String fromCommit, String toCommit) Return a set of base informations between the two given commits.protected org.apache.hc.client5.http.io.HttpClientConnectionManagerGets the default branch in the repository.Iterable<jenkins.scm.api.SCMFile>getDirectoryContent(BitbucketSCMFile parent) Returns a list of all children file for the given folder.jenkins.scm.api.SCMFilegetFile(BitbucketSCMFile file) Return the metadata for the given file.Return an input stream for the given file.protected org.apache.hc.core5.http.HttpHostgetHost()getOwner()Returns the owner name for the repository.Returns a specific pull request.Returns the pull requests in the repository.Returns all the repositories for the current owner (even if it's a regular user or a team).Returns the repositories where the user has the given role.Returns the repository details.Returns the repository name.Returns a tag in the repository.getTags()Returns the tags in the repository.getTeam()Returns the team of the current owner ornullif the current owner is not a team.jenkins.scm.impl.avatars.AvatarImageDeprecated, for removal: This API element is subject to removal in a future version.Returns the webhooks defined in the repository.booleanReturnstrueif and only if the repository is private.protected booleanisSupportedAuthenticator(BitbucketAuthenticator authenticator) Implementation must validate if the configured authenticator is supported by this client implementation.voidpostBuildStatus(BitbucketBuildStatus status) Deprecated.voidpostCommitComment(String hash, String comment) Post a comment to a given commit hash.voidRegister a webhook on the repository.voidRemove the webhook (ID field required) from the repository.Resolve the head commit object of the pull request source repository branch.resolveCommit(String hash) Resolve the commit object given its hash.Resolve the head commit hash of the pull request source repository branch.stats()voidUpdate a webhook on the repository.Methods inherited from class com.cloudbees.jenkins.plugins.bitbucket.impl.client.AbstractBitbucketApi
adapt, buildResponseException, close, connectionManagerBuilder, deleteRequest, executeMethod, getAuthenticator, getRequest, getRequestAsInputStream, getResponseContent, headRequestStatus, postRequest, postRequest, putRequest, setClientProxyParams, setupClientBuilderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketApi
adapt, close
-
Constructor Details
-
BitbucketCloudApiClient
public BitbucketCloudApiClient(boolean enableCache, int teamCacheDuration, int repositoriesCacheDuration, String owner, String projectKey, String repositoryName, BitbucketAuthenticator authenticator)
-
-
Method Details
-
stats
-
clearCaches
public static void clearCaches() -
isSupportedAuthenticator
Description copied from class:AbstractBitbucketApiImplementation must validate if the configured authenticator is supported by this client implementation.- Specified by:
isSupportedAuthenticatorin classAbstractBitbucketApi
-
getOwner
Returns the owner name for the repository.- Specified by:
getOwnerin interfaceBitbucketApi- Returns:
- the repository owner name.
-
getRepositoryName
Returns the repository name.- Specified by:
getRepositoryNamein interfaceBitbucketApi- Returns:
- the repository name.
-
getPullRequests
Returns the pull requests in the repository.- Specified by:
getPullRequestsin interfaceBitbucketApi- Returns:
- the list of pull requests in the repository.
- Throws:
IOException- if there was a network communications error.
-
getPullRequestById
Returns a specific pull request.- Specified by:
getPullRequestByIdin interfaceBitbucketApi- Parameters:
id- the pull request ID- Returns:
- the pull request or null if the PR does not exist
- Throws:
IOException- if there was a network communications error.
-
getRepository
Returns the repository details.- Specified by:
getRepositoryin interfaceBitbucketApi- Returns:
- the repository specified by
BitbucketApi.getOwner()/BitbucketApi.getRepositoryName()(or null if repositoryName is not set) - Throws:
IOException- if there was a network communications error.
-
postCommitComment
Post a comment to a given commit hash.- Specified by:
postCommitCommentin interfaceBitbucketApi- Parameters:
hash- commit hashcomment- string to post as comment- Throws:
IOException- if there was a network communications error.
-
checkPathExists
public boolean checkPathExists(@NonNull String branchOrHash, @NonNull String path) throws IOException Checks if the given path exists in the repository at the specified branch.- Specified by:
checkPathExistsin interfaceBitbucketApi- Parameters:
branchOrHash- the branch name or commit hashpath- the path to check for- Returns:
- true if the path exists
- Throws:
IOException- if there was a network communications error.
-
getDefaultBranch
Gets the default branch in the repository.- Specified by:
getDefaultBranchin interfaceBitbucketApi- Returns:
- the default branch in the repository or null if no default branch set
- Throws:
IOException- if there was a network communications error.
-
getTag
Returns a tag in the repository.- Specified by:
getTagin interfaceBitbucketApi- Returns:
- a tag in the repository.
- Throws:
IOException- if there was a network communications error.
-
getTags
Returns the tags in the repository.- Specified by:
getTagsin interfaceBitbucketApi- Returns:
- the list of tags in the repository.
- Throws:
IOException- if there was a network communications error.
-
getBranch
Returns a branch in the repository.- Specified by:
getBranchin interfaceBitbucketApi- Returns:
- a branch in the repository.
- Throws:
IOException- if there was a network communications error.
-
getBranches
Returns the branches in the repository.- Specified by:
getBranchesin interfaceBitbucketApi- Returns:
- the list of branches in the repository.
- Throws:
IOException- if there was a network communications error.
-
getBranchesByRef
- Throws:
IOException
-
resolveCommit
Resolve the commit object given its hash.- Specified by:
resolveCommitin interfaceBitbucketApi- Parameters:
hash- the hash to resolve- Returns:
- the commit object or null if the hash does not exist
- Throws:
IOException- if there was a network communications error.
-
resolveSourceFullHash
Resolve the head commit hash of the pull request source repository branch.- Specified by:
resolveSourceFullHashin interfaceBitbucketApi- Parameters:
pull- the pull request to resolve the source hash from- Returns:
- the source head hash
- Throws:
IOException- if there was a network communications error.
-
resolveCommit
@NonNull public BitbucketCommit resolveCommit(@NonNull BitbucketPullRequest pull) throws IOException Resolve the head commit object of the pull request source repository branch.- Specified by:
resolveCommitin interfaceBitbucketApi- Parameters:
pull- the pull request to resolve the source hash from- Returns:
- the source head commit object
- Throws:
IOException- if there was a network communications error.
-
registerCommitWebHook
Register a webhook on the repository.- Specified by:
registerCommitWebHookin interfaceBitbucketApi- Overrides:
registerCommitWebHookin classAbstractBitbucketApi- Parameters:
hook- the webhook object- Throws:
IOException- if there was a network communications error.
-
updateCommitWebHook
Update a webhook on the repository.- Specified by:
updateCommitWebHookin interfaceBitbucketApi- Overrides:
updateCommitWebHookin classAbstractBitbucketApi- Parameters:
hook- the webhook object- Throws:
IOException- if there was a network communications error.
-
removeCommitWebHook
Remove the webhook (ID field required) from the repository.- Specified by:
removeCommitWebHookin interfaceBitbucketApi- Overrides:
removeCommitWebHookin classAbstractBitbucketApi- Parameters:
hook- the webhook object- Throws:
IOException- if there was a network communications error.
-
getWebHooks
Returns the webhooks defined in the repository.- Specified by:
getWebHooksin interfaceBitbucketApi- Overrides:
getWebHooksin classAbstractBitbucketApi- Returns:
- the list of webhooks registered in the repository.
- Throws:
IOException- if there was a network communications error.
-
postBuildStatus
Deprecated.Set the build status for the given commit hash.- Specified by:
postBuildStatusin interfaceBitbucketApi- Parameters:
status- the status object to be serialized- Throws:
IOException- if there was a network communications error.
-
isPrivate
Returnstrueif and only if the repository is private.- Specified by:
isPrivatein interfaceBitbucketApi- Returns:
trueif the repository (BitbucketApi.getOwner()/BitbucketApi.getRepositoryName()) is private.- Throws:
IOException- if there was a network communications error.
-
getTeam
Returns the team of the current owner ornullif the current owner is not a team.- Specified by:
getTeamin interfaceBitbucketApi- Returns:
- the team profile of the current owner, or
nullifBitbucketApi.getOwner()is not a team ID. - Throws:
IOException- if there was a network communications error.
-
getTeamAvatar
@Deprecated(since="935.0.0", forRemoval=true) @CheckForNull public jenkins.scm.impl.avatars.AvatarImage getTeamAvatar() throws IOExceptionDeprecated, for removal: This API element is subject to removal in a future version.Returns the team Avatar of the current owner ornullif the current owner is not a team.- Specified by:
getTeamAvatarin interfaceBitbucketApi- Returns:
- the team profile of the current owner, or
nullifBitbucketApi.getOwner()is not a team ID. - Throws:
IOException- if there was a network communications error.
-
getAvatar
@CheckForNull public jenkins.scm.impl.avatars.AvatarImage getAvatar(@CheckForNull String url) throws IOException Description copied from interface:BitbucketApiReturns an Avatar image from the given URL.The URL link could come from repository, project, workspace or user links.
- Specified by:
getAvatarin interfaceBitbucketApi- Returns:
- the resource image.
- Throws:
IOException- if there was a network communications error.
-
getRepositories
@NonNull public List<BitbucketCloudRepository> getRepositories(@CheckForNull UserRoleInRepository role) throws IOException Description copied from interface:BitbucketApiReturns the repositories where the user has the given role.- Specified by:
getRepositoriesin interfaceBitbucketApi- Parameters:
role- Filter repositories by the owner having this role in. SeeUserRoleInRepositoryfor more information. Use role = null if the repoOwner is a team ID.- Returns:
- the repositories list (it can be empty)
- Throws:
IOException- if there was a network communications error.
-
getRepositories
Returns all the repositories for the current owner (even if it's a regular user or a team).- Specified by:
getRepositoriesin interfaceBitbucketApi- Returns:
- all repositories for the current
BitbucketApi.getOwner() - Throws:
IOException- if there was a network communications error.
-
getConnectionManager
protected org.apache.hc.client5.http.io.HttpClientConnectionManager getConnectionManager()- Specified by:
getConnectionManagerin classAbstractBitbucketApi
-
getHost
@NonNull protected org.apache.hc.core5.http.HttpHost getHost()- Specified by:
getHostin classAbstractBitbucketApi
-
getBaseURL
- Specified by:
getBaseURLin classAbstractBitbucketApi
-
getClient
@NonNull protected org.apache.hc.client5.http.impl.classic.CloseableHttpClient getClient()- Specified by:
getClientin classAbstractBitbucketApi
-
getDirectoryContent
public Iterable<jenkins.scm.api.SCMFile> getDirectoryContent(BitbucketSCMFile parent) throws IOException Description copied from interface:BitbucketApiReturns a list of all children file for the given folder.- Specified by:
getDirectoryContentin interfaceBitbucketApi- Parameters:
parent- to list- Returns:
- an iterable of
SCMFilechildren of the given folder. - Throws:
IOException- if there was a network communications error.
-
getFileContent
Description copied from interface:BitbucketApiReturn an input stream for the given file.- Specified by:
getFileContentin interfaceBitbucketApi- Parameters:
file- an instance of SCM file- Returns:
- the stream of the given
SCMFile - Throws:
IOException- if there was a network communications error.
-
getFile
Description copied from interface:BitbucketApiReturn the metadata for the given file.- Specified by:
getFilein interfaceBitbucketApi- Parameters:
file- an instance of SCM file- Returns:
- a
SCMFilefile with updated the metadata - Throws:
IOException- if there was a network communications error.
-
getCommits
@NonNull public List<BitbucketCloudCommit> getCommits(@CheckForNull String fromCommit, @NonNull String toCommit) throws IOException Description copied from interface:BitbucketApiReturn a set of base informations between the two given commits.- Specified by:
getCommitsin interfaceBitbucketApi- Parameters:
fromCommit- the commit or reference containing the changes we wish to preview ornullto get changes since the beginning.toCommit- the commit or reference representing the state to which we want to compare the first commit- Returns:
- the list of commit between first commit and second source commit.
- Throws:
IOException- if there was a network communications error.
-