Class BitbucketServerApi
- java.lang.Object
-
- io.jenkins.blueocean.blueocean_bitbucket_pipeline.BitbucketApi
-
- io.jenkins.blueocean.blueocean_bitbucket_pipeline.server.BitbucketServerApi
-
public class BitbucketServerApi extends BitbucketApi
- Author:
- Vivek Pandey
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BitbucketServerApi.BitbucketServerApiFactory
-
Field Summary
Fields Modifier and Type Field Description static VersionNumber
MINIMUM_SUPPORTED_VERSION
-
Fields inherited from class io.jenkins.blueocean.blueocean_bitbucket_pipeline.BitbucketApi
apiUrl, request, userName
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BbBranch
createBranch(String orgId, String repoSlug, Map<String,String> payload)
Create branch.boolean
fileExists(String projectKey, String repoSlug, String path, String branch)
Checks if a file exists in Bitbucket repo.BbBranch
getBranch(String orgId, String repoSlug, String branch)
Gives Bitbucket branchString
getContent(String orgId, String repoSlug, String path, String commitId)
Gives content of files in Bitbucket.BbBranch
getDefaultBranch(String orgId, String repoSlug)
Get default branch of a repo.BbOrg
getOrg(String projectName)
GivesBbOrg
for given project/team name.BbPage<BbOrg>
getOrgs(int pageNumber, int pageSize)
Gives collection of Bitbucket organizations (Project/Team).BbRepo
getRepo(String orgId, String repoSlug)
GivesBbRepo
BbPage<BbRepo>
getRepos(String projectKey, int pageNumber, int pageSize)
Gives collection ofBbRepo
s.BbServerUser
getUser(String userName)
Gives user for given userName.static String
getVersion(String apiUrl)
Gives Bitbucket server versionboolean
isEmptyRepo(String orgId, String repoSlug)
Checks if its empty/un-initializedstatic boolean
isSupportedVersion(String version)
Tells whether given version is supported version.BbSaveContentResponse
saveContent(String projectKey, String repoSlug, String path, String content, String commitMessage, String branch, String sourceBranch, String commitId)
Saves file to Bitbucket.-
Methods inherited from class io.jenkins.blueocean.blueocean_bitbucket_pipeline.BitbucketApi
ensureTrailingSlash, getUser, handleException
-
-
-
-
Field Detail
-
MINIMUM_SUPPORTED_VERSION
public static final VersionNumber MINIMUM_SUPPORTED_VERSION
-
-
Method Detail
-
getVersion
@NonNull public static String getVersion(@NonNull String apiUrl)
Gives Bitbucket server version- Parameters:
apiUrl
- API url of Bitbucket server- Returns:
- version of Bitbucket server
-
getUser
@NonNull public BbServerUser getUser(@NonNull String userName)
Description copied from class:BitbucketApi
Gives user for given userName.- Specified by:
getUser
in classBitbucketApi
- Parameters:
userName
- name of user,BbUser.getSlug()
- Returns:
BbUser
-
getOrgs
@NonNull public BbPage<BbOrg> getOrgs(int pageNumber, int pageSize)
Description copied from class:BitbucketApi
Gives collection of Bitbucket organizations (Project/Team).- Specified by:
getOrgs
in classBitbucketApi
- Parameters:
pageNumber
- page numberpageSize
- number of items in a page- Returns:
- Collection of
BbOrg
s
-
getOrg
@NonNull public BbOrg getOrg(@NonNull String projectName)
Description copied from class:BitbucketApi
GivesBbOrg
for given project/team name.- Specified by:
getOrg
in classBitbucketApi
- Parameters:
projectName
- Bitbucket project/team keyBbOrg.getKey()
- Returns:
BbOrg
instance
-
getRepos
@NonNull public BbPage<BbRepo> getRepos(@NonNull String projectKey, int pageNumber, int pageSize)
Description copied from class:BitbucketApi
Gives collection ofBbRepo
s.- Specified by:
getRepos
in classBitbucketApi
- Parameters:
projectKey
- Bitbucket project/team keyBbOrg.getKey()
pageNumber
- page numberpageSize
- page size- Returns:
-
getRepo
@NonNull public BbRepo getRepo(@NonNull String orgId, @NonNull String repoSlug)
Description copied from class:BitbucketApi
GivesBbRepo
- Specified by:
getRepo
in classBitbucketApi
- Parameters:
orgId
- Bitbucket project/team keyBbOrg.getKey()
repoSlug
- repo slugBbRepo.getSlug()
- Returns:
BbRepo
instance
-
getContent
@NonNull public String getContent(@NonNull String orgId, @NonNull String repoSlug, @NonNull String path, @NonNull String commitId)
Description copied from class:BitbucketApi
Gives content of files in Bitbucket. If given path is not available thenServiceException.NotFoundException
is thrown.- Specified by:
getContent
in classBitbucketApi
- Parameters:
orgId
- Bitbucket project/team keyBbOrg.getKey()
repoSlug
- Bitbucket repo sligBbRepo.getSlug()
path
- path to file in bitbucket repo, e.g. "Jenkinsfile"commitId
- commitId of branch, path will be served off it.- Returns:
- content
-
saveContent
@NonNull public BbSaveContentResponse saveContent(@NonNull String projectKey, @NonNull String repoSlug, @NonNull String path, @NonNull String content, @NonNull String commitMessage, @Nullable String branch, @Nullable String sourceBranch, @Nullable String commitId)
Description copied from class:BitbucketApi
Saves file to Bitbucket.- Specified by:
saveContent
in classBitbucketApi
- Parameters:
projectKey
- Bitbucket project/team keyBbOrg.getKey()
repoSlug
- Repo slugBbRepo.getSlug()
path
- destination path, e.g. "Jenkinsfile"content
- file content to savecommitMessage
- commit messagebranch
- branch name. If null then implementation should save on default branchcommitId
- if not provided, then file should be saved on tip of branch.- Returns:
BbSaveContentResponse
on successful save.
-
fileExists
public boolean fileExists(@NonNull String projectKey, @NonNull String repoSlug, @NonNull String path, @NonNull String branch)
Description copied from class:BitbucketApi
Checks if a file exists in Bitbucket repo.- Specified by:
fileExists
in classBitbucketApi
- Parameters:
projectKey
- Bitbucket project/team keyBbOrg.getKey()
repoSlug
- repo slugBbRepo.getSlug()
path
- path of file, e.g. "Jenkinsfile"branch
- Bitbucket branchBbBranch.getDisplayId()
- Returns:
- true if file exists
-
getBranch
@CheckForNull public BbBranch getBranch(@NonNull String orgId, @NonNull String repoSlug, @NonNull String branch)
Description copied from class:BitbucketApi
Gives Bitbucket branch- Specified by:
getBranch
in classBitbucketApi
- Parameters:
orgId
- Bitbucket project/team keyBbOrg.getKey()
repoSlug
- Repo slugBbRepo.getSlug()
branch
- branch nameBbBranch.getDisplayId()
- Returns:
BbBranch
instance. Could be null if there is no such branch.
-
createBranch
@NonNull public BbBranch createBranch(@NonNull String orgId, @NonNull String repoSlug, Map<String,String> payload)
Description copied from class:BitbucketApi
Create branch.- Specified by:
createBranch
in classBitbucketApi
- Parameters:
orgId
- Bitbucket project/team keyBbOrg.getKey()
repoSlug
- repo slugBbRepo.getSlug()
payload
- branch payload- Returns:
- Created branch
-
getDefaultBranch
@CheckForNull public BbBranch getDefaultBranch(@NonNull String orgId, @NonNull String repoSlug)
Description copied from class:BitbucketApi
Get default branch of a repo.- Specified by:
getDefaultBranch
in classBitbucketApi
- Parameters:
orgId
- Bitbucket project/team keyBbOrg.getKey()
repoSlug
- Repo slugBbRepo.getSlug()
- Returns:
- Default branch. null if it's empty repo or if the scm doesn't support default branch concept.
-
isEmptyRepo
public boolean isEmptyRepo(@NonNull String orgId, @NonNull String repoSlug)
Description copied from class:BitbucketApi
Checks if its empty/un-initialized- Specified by:
isEmptyRepo
in classBitbucketApi
- Parameters:
orgId
- Bitbucket project/team keyBbOrg.getKey()
repoSlug
- Repo slugBbRepo.getSlug()
- Returns:
- true if this is empty or un-initialized repo
-
isSupportedVersion
public static boolean isSupportedVersion(@NonNull String version)
Tells whether given version is supported version.- Parameters:
version
- version of Bitbucket server to test- Returns:
- true if supported false otherwise
- See Also:
getVersion(String)
-
-