public class BitbucketCloudApiClient extends Object implements BitbucketApi
Constructor and Description |
---|
BitbucketCloudApiClient(boolean enableCache,
int teamCacheDuration,
int repositoriesCacheDuration,
String owner,
String repositoryName,
BitbucketAuthenticator authenticator) |
BitbucketCloudApiClient(boolean enableCache,
int teamCacheDuration,
int repositoriesCacheDuration,
String owner,
String repositoryName,
com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials credentials)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkPathExists(String branchOrHash,
String path)
Checks if the given path exists in the repository at the specified branch.
|
static void |
clearCaches() |
protected org.apache.http.client.methods.CloseableHttpResponse |
executeMethod(org.apache.http.HttpHost host,
org.apache.http.client.methods.HttpRequestBase httpMethod) |
protected org.apache.http.client.methods.CloseableHttpResponse |
executeMethod(org.apache.http.client.methods.HttpRequestBase httpMethod) |
protected void |
finalize() |
List<BitbucketCloudBranch> |
getBranches()
Returns the branches in the repository.
|
List<BitbucketCloudBranch> |
getBranchesByRef(String nodePath) |
String |
getDefaultBranch()
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.
|
InputStream |
getFileContent(BitbucketSCMFile file)
Return an input stream for the given file.
|
String |
getLogin()
Deprecated.
|
String |
getOwner()
Returns the owner name for the repository.
|
BitbucketPullRequest |
getPullRequestById(Integer id)
Returns a specific pull request.
|
List<BitbucketPullRequestValue> |
getPullRequests()
Returns the pull requests in the repository.
|
List<BitbucketCloudRepository> |
getRepositories()
Returns all the repositories for the current owner (even if it's a regular user or a team).
|
List<BitbucketCloudRepository> |
getRepositories(UserRoleInRepository role)
The role parameter only makes sense when the request is authenticated, so
if there is no auth information (
authenticator ) the role will be omitted. |
BitbucketRepository |
getRepository()
Returns the repository details.
|
String |
getRepositoryName()
Returns the repository name.
|
String |
getRepositoryUri(BitbucketRepositoryProtocol protocol,
String cloneLink,
String owner,
String repository)
Returns the URI of the repository.
|
List<BitbucketCloudBranch> |
getTags()
Returns the tags in the repository.
|
BitbucketTeam |
getTeam()
Returns the team of the current owner or
null if the current owner is not a team. |
AvatarCacheSource.AvatarImage |
getTeamAvatar()
Returns the team Avatar of the current owner or
null if the current owner is not a team. |
List<BitbucketRepositoryHook> |
getWebHooks()
Returns the webhooks defined in the repository.
|
boolean |
isPrivate()
Returns
true 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 |
registerCommitWebHook(BitbucketWebHook hook)
Register a webhook on the repository.
|
void |
removeCommitWebHook(BitbucketWebHook hook)
Remove the webhook (ID field required) from the repository.
|
BitbucketCommit |
resolveCommit(BitbucketPullRequest pull)
Resolve the head commit object of the pull request source repository branch.
|
BitbucketCommit |
resolveCommit(String hash)
Resolve the commit object given its hash.
|
String |
resolveSourceFullHash(BitbucketPullRequest pull)
Resolve the head commit hash of the pull request source repository branch.
|
static List<String> |
stats() |
void |
updateCommitWebHook(BitbucketWebHook hook)
Update a webhook on the repository.
|
@Deprecated public BitbucketCloudApiClient(boolean enableCache, int teamCacheDuration, int repositoriesCacheDuration, String owner, String repositoryName, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials credentials)
public BitbucketCloudApiClient(boolean enableCache, int teamCacheDuration, int repositoriesCacheDuration, String owner, String repositoryName, BitbucketAuthenticator authenticator)
public static void clearCaches()
protected void finalize() throws Throwable
@NonNull public String getOwner()
getOwner
in interface BitbucketApi
@CheckForNull public String getRepositoryName()
getRepositoryName
in interface BitbucketApi
@NonNull public String getRepositoryUri(@NonNull BitbucketRepositoryProtocol protocol, @CheckForNull String cloneLink, @NonNull String owner, @NonNull String repository)
getRepositoryUri
in interface BitbucketApi
protocol
- the protocol to access the repository with.cloneLink
- the actual clone link for the repository as sent by the server, or null
if unknown.owner
- the ownerrepository
- the repository.@NonNull public List<BitbucketPullRequestValue> getPullRequests() throws InterruptedException, IOException
getPullRequests
in interface BitbucketApi
InterruptedException
- if interrupted while waiting on remote communications.IOException
- if there was a network communications error.@Deprecated @CheckForNull public String getLogin()
@NonNull public BitbucketPullRequest getPullRequestById(@NonNull Integer id) throws IOException, InterruptedException
getPullRequestById
in interface BitbucketApi
id
- the pull request IDIOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@NonNull public BitbucketRepository getRepository() throws IOException, InterruptedException
getRepository
in interface BitbucketApi
BitbucketApi.getOwner()
/BitbucketApi.getRepositoryName()
(or null if repositoryName is not set)IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.public void postCommitComment(@NonNull String hash, @NonNull String comment) throws IOException, InterruptedException
postCommitComment
in interface BitbucketApi
hash
- commit hashcomment
- string to post as commentIOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.public boolean checkPathExists(@NonNull String branchOrHash, @NonNull String path) throws IOException, InterruptedException
checkPathExists
in interface BitbucketApi
branchOrHash
- the branch name or commit hashpath
- the path to check forIOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@CheckForNull public String getDefaultBranch() throws IOException, InterruptedException
getDefaultBranch
in interface BitbucketApi
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@NonNull public List<BitbucketCloudBranch> getTags() throws IOException, InterruptedException
getTags
in interface BitbucketApi
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@NonNull public List<BitbucketCloudBranch> getBranches() throws IOException, InterruptedException
getBranches
in interface BitbucketApi
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.public List<BitbucketCloudBranch> getBranchesByRef(String nodePath) throws IOException, InterruptedException
IOException
InterruptedException
@CheckForNull public BitbucketCommit resolveCommit(@NonNull String hash) throws IOException, InterruptedException
resolveCommit
in interface BitbucketApi
hash
- the hash to resolveIOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@NonNull public String resolveSourceFullHash(@NonNull BitbucketPullRequest pull) throws IOException, InterruptedException
resolveSourceFullHash
in interface BitbucketApi
pull
- the pull request to resolve the source hash fromIOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@NonNull public BitbucketCommit resolveCommit(@NonNull BitbucketPullRequest pull) throws IOException, InterruptedException
resolveCommit
in interface BitbucketApi
pull
- the pull request to resolve the source hash fromIOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.public void registerCommitWebHook(@NonNull BitbucketWebHook hook) throws IOException, InterruptedException
registerCommitWebHook
in interface BitbucketApi
hook
- the webhook objectIOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.public void updateCommitWebHook(@NonNull BitbucketWebHook hook) throws IOException, InterruptedException
updateCommitWebHook
in interface BitbucketApi
hook
- the webhook objectIOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.public void removeCommitWebHook(@NonNull BitbucketWebHook hook) throws IOException, InterruptedException
removeCommitWebHook
in interface BitbucketApi
hook
- the webhook objectIOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@NonNull public List<BitbucketRepositoryHook> getWebHooks() throws IOException, InterruptedException
getWebHooks
in interface BitbucketApi
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.public void postBuildStatus(@NonNull BitbucketBuildStatus status) throws IOException, InterruptedException
postBuildStatus
in interface BitbucketApi
status
- the status object to be serializedIOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.public boolean isPrivate() throws IOException, InterruptedException
true
if and only if the repository is private.isPrivate
in interface BitbucketApi
true
if the repository (BitbucketApi.getOwner()
/BitbucketApi.getRepositoryName()
) is private.IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@CheckForNull public BitbucketTeam getTeam() throws IOException, InterruptedException
null
if the current owner is not a team.getTeam
in interface BitbucketApi
null
if BitbucketApi.getOwner()
is not a team ID.IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@CheckForNull public AvatarCacheSource.AvatarImage getTeamAvatar() throws IOException, InterruptedException
null
if the current owner is not a team.getTeamAvatar
in interface BitbucketApi
null
if BitbucketApi.getOwner()
is not a team ID.IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@NonNull public List<BitbucketCloudRepository> getRepositories(@CheckForNull UserRoleInRepository role) throws InterruptedException, IOException
authenticator
) the role will be omitted.getRepositories
in interface BitbucketApi
role
- Filter repositories by the owner having this role in.
See UserRoleInRepository
for more information.
Use role = null if the repoOwner is a team ID.InterruptedException
- if interrupted while waiting on remote communications.IOException
- if there was a network communications error.@NonNull public List<BitbucketCloudRepository> getRepositories() throws IOException, InterruptedException
getRepositories
in interface BitbucketApi
BitbucketApi.getOwner()
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@Restricted(value=org.kohsuke.accmod.restrictions.ProtectedExternally.class) protected org.apache.http.client.methods.CloseableHttpResponse executeMethod(org.apache.http.client.methods.HttpRequestBase httpMethod) throws InterruptedException, IOException
InterruptedException
IOException
@Restricted(value=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
InterruptedException
IOException
public Iterable<jenkins.scm.api.SCMFile> getDirectoryContent(BitbucketSCMFile parent) throws IOException, InterruptedException
BitbucketApi
getDirectoryContent
in interface BitbucketApi
parent
- to listSCMFile
children of the given folder.IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.public InputStream getFileContent(BitbucketSCMFile file) throws IOException, InterruptedException
BitbucketApi
getFileContent
in interface BitbucketApi
file
- and instance of SCM fileSCMFile
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.Copyright © 2016–2022. All rights reserved.