public class BitbucketServerAPIClient extends Object implements BitbucketApi
Constructor and Description |
---|
BitbucketServerAPIClient(String baseURL,
String owner,
String repositoryName,
BitbucketAuthenticator authenticator,
boolean userCentric) |
BitbucketServerAPIClient(String baseURL,
String owner,
String repositoryName,
BitbucketAuthenticator authenticator,
boolean userCentric,
BitbucketServerWebhookImplementation webhookImplementation) |
BitbucketServerAPIClient(String baseURL,
String owner,
String repositoryName,
com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials credentials,
boolean userCentric)
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.
|
protected org.apache.http.client.methods.CloseableHttpResponse |
executeMethodNoRetry(org.apache.http.impl.client.CloseableHttpClient client,
org.apache.http.client.methods.HttpRequestBase httpMethod,
org.apache.http.client.protocol.HttpClientContext context) |
List<BitbucketServerBranch> |
getBranches()
Returns the branches in the repository.
|
String |
getDefaultBranch()
Gets the default branch in the repository.
|
Iterable<jenkins.scm.api.SCMFile> |
getDirectoryContent(BitbucketSCMFile directory)
Returns a list of all children file for the given folder.
|
InputStream |
getFileContent(BitbucketSCMFile file)
Return an input stream for the given file.
|
List<BitbucketServerPullRequest> |
getIncomingOpenPullRequests(String toRef) |
List<BitbucketServerPullRequest> |
getOutgoingOpenPullRequests(String fromRef) |
String |
getOwner()
Bitbucket Server manages two top level entities, owner and/or project.
|
BitbucketPullRequest |
getPullRequestById(Integer id)
Returns a specific pull request.
|
List<BitbucketServerPullRequest> |
getPullRequests()
Returns the pull requests in the repository.
|
List<BitbucketServerRepository> |
getRepositories()
Returns all the repositories for the current owner (even if it's a regular user or a team).
|
List<BitbucketServerRepository> |
getRepositories(UserRoleInRepository role)
The role parameter is ignored for Bitbucket Server.
|
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.
|
protected String |
getRequest(String path) |
List<BitbucketServerBranch> |
getTags()
Returns the tags in the repository.
|
BitbucketTeam |
getTeam()
There is no such Team concept in Bitbucket Server but Project.
|
AvatarCacheSource.AvatarImage |
getTeamAvatar()
Get Team avatar
|
String |
getUserCentricOwner()
In Bitbucket server the top level entity is the Project, but the JSON API accepts users as a replacement
of Projects in most of the URLs (it's called user centric API).
|
List<? extends BitbucketWebHook> |
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.
|
void |
updateCommitWebHook(BitbucketWebHook hook)
Update a webhook on the repository.
|
@Deprecated public BitbucketServerAPIClient(@NonNull String baseURL, @NonNull String owner, @CheckForNull String repositoryName, @CheckForNull com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials credentials, boolean userCentric)
public BitbucketServerAPIClient(@NonNull String baseURL, @NonNull String owner, @CheckForNull String repositoryName, @CheckForNull BitbucketAuthenticator authenticator, boolean userCentric)
public BitbucketServerAPIClient(@NonNull String baseURL, @NonNull String owner, @CheckForNull String repositoryName, @CheckForNull BitbucketAuthenticator authenticator, boolean userCentric, @NonNull BitbucketServerWebhookImplementation webhookImplementation)
@NonNull public String getOwner()
getOwner
in interface BitbucketApi
public String getUserCentricOwner()
@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<BitbucketServerPullRequest> getPullRequests() throws IOException, InterruptedException
getPullRequests
in interface BitbucketApi
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@NonNull public List<BitbucketServerPullRequest> getOutgoingOpenPullRequests(String fromRef) throws IOException, InterruptedException
IOException
InterruptedException
@NonNull public List<BitbucketServerPullRequest> getIncomingOpenPullRequests(String toRef) throws IOException, InterruptedException
IOException
InterruptedException
@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 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 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
BitbucketApi
getDefaultBranch
in interface BitbucketApi
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@NonNull public List<BitbucketServerBranch> 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<BitbucketServerBranch> getBranches() throws IOException, InterruptedException
getBranches
in interface BitbucketApi
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@NonNull 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)
resolveSourceFullHash
in interface BitbucketApi
pull
- the pull request to resolve the source hash from@NonNull public BitbucketCommit resolveCommit(@NonNull BitbucketPullRequest pull) throws IOException, InterruptedException
BitbucketApi
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(BitbucketWebHook hook) throws IOException, InterruptedException
BitbucketApi
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(BitbucketWebHook hook) throws IOException, InterruptedException
BitbucketApi
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(BitbucketWebHook hook) throws IOException, InterruptedException
BitbucketApi
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<? extends BitbucketWebHook> getWebHooks() throws IOException, InterruptedException
BitbucketApi
getWebHooks
in interface BitbucketApi
IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.public BitbucketTeam getTeam() throws IOException, InterruptedException
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.public AvatarCacheSource.AvatarImage getTeamAvatar() throws IOException
getTeamAvatar
in interface BitbucketApi
null
if BitbucketApi.getOwner()
is not a team ID.IOException
- if there was a network communications error.@NonNull public List<BitbucketServerRepository> getRepositories(@CheckForNull UserRoleInRepository role) throws IOException, InterruptedException
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.IOException
- if there was a network communications error.InterruptedException
- if interrupted while waiting on remote communications.@NonNull public List<BitbucketServerRepository> 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.public boolean isPrivate() throws IOException, InterruptedException
BitbucketApi
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.protected String getRequest(String path) throws IOException, InterruptedException
IOException
InterruptedException
public Iterable<jenkins.scm.api.SCMFile> getDirectoryContent(BitbucketSCMFile directory) throws IOException, InterruptedException
BitbucketApi
getDirectoryContent
in interface BitbucketApi
directory
- 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.@Restricted(value=org.kohsuke.accmod.restrictions.ProtectedExternally.class) protected org.apache.http.client.methods.CloseableHttpResponse executeMethodNoRetry(org.apache.http.impl.client.CloseableHttpClient client, org.apache.http.client.methods.HttpRequestBase httpMethod, org.apache.http.client.protocol.HttpClientContext context) throws IOException, InterruptedException
IOException
InterruptedException
Copyright © 2016–2022. All rights reserved.