Class BitbucketCloudApiClient
java.lang.Object
com.cloudbees.jenkins.plugins.bitbucket.internal.api.AbstractBitbucketApi
com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient
- All Implemented Interfaces:
BitbucketApi
-
Field Summary
Fields inherited from class com.cloudbees.jenkins.plugins.bitbucket.internal.api.AbstractBitbucketApi
API_RATE_LIMIT_STATUS_CODE, context, logger
-
Constructor Summary
ConstructorDescriptionBitbucketCloudApiClient
(boolean enableCache, int teamCacheDuration, int repositoriesCacheDuration, String owner, String repositoryName, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials credentials) Deprecated.BitbucketCloudApiClient
(boolean enableCache, int teamCacheDuration, int repositoriesCacheDuration, String owner, String projectKey, String repositoryName, BitbucketAuthenticator authenticator) -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkPathExists
(String branchOrHash, String path) Checks if the given path exists in the repository at the specified branch.static void
protected org.apache.http.client.methods.CloseableHttpResponse
executeMethod
(org.apache.http.client.methods.HttpRequestBase httpMethod) protected org.apache.http.client.methods.CloseableHttpResponse
executeMethod
(org.apache.http.HttpHost host, org.apache.http.client.methods.HttpRequestBase httpMethod) protected void
finalize()
Returns a branch in the repository.Returns the branches in the repository.getBranchesByRef
(String nodePath) Gets 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.Return an input stream for the given file.getLogin()
Deprecated.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).The role parameter only makes sense when the request is authenticated, so if there is no auth information (authenticator
) the role will be omitted.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 ornull
if the current owner is not a team.Returns the team Avatar of the current owner ornull
if the current owner is not a team.Returns the webhooks defined in the repository.boolean
Returnstrue
if and only if the repository is private.void
postBuildStatus
(BitbucketBuildStatus status) Set the build status for the given commit hash.void
postCommitComment
(String hash, String comment) Post a comment to a given commit hash.void
Register a webhook on the repository.void
Remove 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()
void
Update a webhook on the repository.Methods inherited from class com.cloudbees.jenkins.plugins.bitbucket.internal.api.AbstractBitbucketApi
buildResponseException, getResponseContent, setClientProxyParams, truncateMiddle
-
Constructor Details
-
BitbucketCloudApiClient
@Deprecated public BitbucketCloudApiClient(boolean enableCache, int teamCacheDuration, int repositoriesCacheDuration, String owner, String repositoryName, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials credentials) Deprecated. -
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() -
finalize
-
getOwner
Returns the owner name for the repository.- Specified by:
getOwner
in interfaceBitbucketApi
- Returns:
- the repository owner name.
-
getRepositoryName
Returns the repository name.- Specified by:
getRepositoryName
in interfaceBitbucketApi
- Returns:
- the repository name.
-
getPullRequests
@NonNull public List<BitbucketPullRequestValue> getPullRequests() throws InterruptedException, IOExceptionReturns the pull requests in the repository.- Specified by:
getPullRequests
in interfaceBitbucketApi
- Returns:
- the list of pull requests in the repository.
- Throws:
InterruptedException
- if interrupted while waiting on remote communications.IOException
- if there was a network communications error.
-
getLogin
Deprecated. -
getPullRequestById
@NonNull public BitbucketPullRequest getPullRequestById(@NonNull Integer id) throws IOException, InterruptedException Returns a specific pull request.- Specified by:
getPullRequestById
in 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.InterruptedException
- if interrupted while waiting on remote communications.
-
getRepository
Returns the repository details.- Specified by:
getRepository
in 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.InterruptedException
- if interrupted while waiting on remote communications.
-
postCommitComment
public void postCommitComment(@NonNull String hash, @NonNull String comment) throws IOException, InterruptedException Post a comment to a given commit hash.- Specified by:
postCommitComment
in interfaceBitbucketApi
- Parameters:
hash
- commit hashcomment
- string to post as comment- Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
checkPathExists
public boolean checkPathExists(@NonNull String branchOrHash, @NonNull String path) throws IOException, InterruptedException Checks if the given path exists in the repository at the specified branch.- Specified by:
checkPathExists
in 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.InterruptedException
- if interrupted while waiting on remote communications.
-
getDefaultBranch
Gets the default branch in the repository.- Specified by:
getDefaultBranch
in interfaceBitbucketApi
- Returns:
- the default branch in the repository or null if no default branch set
- Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
getTag
public BitbucketCloudBranch getTag(@NonNull String tagName) throws IOException, InterruptedException Returns a tag in the repository.- Specified by:
getTag
in interfaceBitbucketApi
- Returns:
- a tag in the repository.
- Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
getTags
Returns the tags in the repository.- Specified by:
getTags
in interfaceBitbucketApi
- Returns:
- the list of tags in the repository.
- Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
getBranch
public BitbucketCloudBranch getBranch(@NonNull String branchName) throws IOException, InterruptedException Returns a branch in the repository.- Specified by:
getBranch
in interfaceBitbucketApi
- Returns:
- a branch in the repository.
- Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
getBranches
Returns the branches in the repository.- Specified by:
getBranches
in interfaceBitbucketApi
- Returns:
- the list of branches in the repository.
- Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
getBranchesByRef
public List<BitbucketCloudBranch> getBranchesByRef(String nodePath) throws IOException, InterruptedException - Throws:
IOException
InterruptedException
-
resolveCommit
@CheckForNull public BitbucketCommit resolveCommit(@NonNull String hash) throws IOException, InterruptedException Resolve the commit object given its hash.- Specified by:
resolveCommit
in 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.InterruptedException
- if interrupted while waiting on remote communications.
-
resolveSourceFullHash
@NonNull public String resolveSourceFullHash(@NonNull BitbucketPullRequest pull) throws IOException, InterruptedException Resolve the head commit hash of the pull request source repository branch.- Specified by:
resolveSourceFullHash
in 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.InterruptedException
- if interrupted while waiting on remote communications.
-
resolveCommit
@NonNull public BitbucketCommit resolveCommit(@NonNull BitbucketPullRequest pull) throws IOException, InterruptedException Resolve the head commit object of the pull request source repository branch.- Specified by:
resolveCommit
in 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.InterruptedException
- if interrupted while waiting on remote communications.
-
registerCommitWebHook
public void registerCommitWebHook(@NonNull BitbucketWebHook hook) throws IOException, InterruptedException Register a webhook on the repository.- Specified by:
registerCommitWebHook
in interfaceBitbucketApi
- Parameters:
hook
- the webhook object- Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
updateCommitWebHook
public void updateCommitWebHook(@NonNull BitbucketWebHook hook) throws IOException, InterruptedException Update a webhook on the repository.- Specified by:
updateCommitWebHook
in interfaceBitbucketApi
- Parameters:
hook
- the webhook object- Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
removeCommitWebHook
public void removeCommitWebHook(@NonNull BitbucketWebHook hook) throws IOException, InterruptedException Remove the webhook (ID field required) from the repository.- Specified by:
removeCommitWebHook
in interfaceBitbucketApi
- Parameters:
hook
- the webhook object- Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
getWebHooks
@NonNull public List<BitbucketRepositoryHook> getWebHooks() throws IOException, InterruptedExceptionReturns the webhooks defined in the repository.- Specified by:
getWebHooks
in interfaceBitbucketApi
- Returns:
- the list of webhooks registered in the repository.
- Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
postBuildStatus
public void postBuildStatus(@NonNull BitbucketBuildStatus status) throws IOException, InterruptedException Set the build status for the given commit hash.- Specified by:
postBuildStatus
in interfaceBitbucketApi
- Parameters:
status
- the status object to be serialized- Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
isPrivate
Returnstrue
if and only if the repository is private.- Specified by:
isPrivate
in interfaceBitbucketApi
- Returns:
true
if the repository (BitbucketApi.getOwner()
/BitbucketApi.getRepositoryName()
) is private.- Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
getTeam
Returns the team of the current owner ornull
if the current owner is not a team.- Specified by:
getTeam
in interfaceBitbucketApi
- Returns:
- the team profile of the current owner, or
null
ifBitbucketApi.getOwner()
is not a team ID. - Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
getTeamAvatar
@CheckForNull public AvatarCacheSource.AvatarImage getTeamAvatar() throws IOException, InterruptedExceptionReturns the team Avatar of the current owner ornull
if the current owner is not a team.- Specified by:
getTeamAvatar
in interfaceBitbucketApi
- Returns:
- the team profile of the current owner, or
null
ifBitbucketApi.getOwner()
is not a team ID. - Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
getRepositories
@NonNull public List<BitbucketCloudRepository> getRepositories(@CheckForNull UserRoleInRepository role) throws InterruptedException, IOException The role parameter only makes sense when the request is authenticated, so if there is no auth information (authenticator
) the role will be omitted.- Specified by:
getRepositories
in interfaceBitbucketApi
- Parameters:
role
- Filter repositories by the owner having this role in. SeeUserRoleInRepository
for more information. Use role = null if the repoOwner is a team ID.- Returns:
- the repositories list (it can be empty)
- Throws:
InterruptedException
- if interrupted while waiting on remote communications.IOException
- if there was a network communications error.
-
getRepositories
@NonNull public List<BitbucketCloudRepository> getRepositories() throws IOException, InterruptedExceptionReturns all the repositories for the current owner (even if it's a regular user or a team).- Specified by:
getRepositories
in interfaceBitbucketApi
- Returns:
- all repositories for the current
BitbucketApi.getOwner()
- Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
executeMethod
@Restricted(org.kohsuke.accmod.restrictions.ProtectedExternally.class) protected org.apache.http.client.methods.CloseableHttpResponse executeMethod(org.apache.http.client.methods.HttpRequestBase httpMethod) throws InterruptedException, IOException - Throws:
InterruptedException
IOException
-
executeMethod
@Restricted(org.kohsuke.accmod.restrictions.ProtectedExternally.class) protected org.apache.http.client.methods.CloseableHttpResponse executeMethod(org.apache.http.HttpHost host, org.apache.http.client.methods.HttpRequestBase httpMethod) throws InterruptedException, IOException - Throws:
InterruptedException
IOException
-
getDirectoryContent
public Iterable<jenkins.scm.api.SCMFile> getDirectoryContent(BitbucketSCMFile parent) throws IOException, InterruptedException Description copied from interface:BitbucketApi
Returns a list of all children file for the given folder.- Specified by:
getDirectoryContent
in interfaceBitbucketApi
- Parameters:
parent
- to list- Returns:
- an iterable of
SCMFile
children of the given folder. - Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-
getFileContent
Description copied from interface:BitbucketApi
Return an input stream for the given file.- Specified by:
getFileContent
in interfaceBitbucketApi
- Parameters:
file
- and instance of SCM file- Returns:
- the stream of the given
SCMFile
- Throws:
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.
-