Class BitbucketServerApi
java.lang.Object
io.jenkins.blueocean.blueocean_bitbucket_pipeline.BitbucketApi
io.jenkins.blueocean.blueocean_bitbucket_pipeline.server.BitbucketServerApi
- Author:
- Vivek Pandey
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class io.jenkins.blueocean.blueocean_bitbucket_pipeline.BitbucketApi
apiUrl, request, userName -
Method Summary
Modifier and TypeMethodDescriptionCreate branch.booleanfileExists(String projectKey, String repoSlug, String path, String branch) Checks if a file exists in Bitbucket repo.Gives Bitbucket branchgetContent(String orgId, String repoSlug, String path, String commitId) Gives content of files in Bitbucket.getDefaultBranch(String orgId, String repoSlug) Get default branch of a repo.GivesBbOrgfor given project/team name.getOrgs(int pageNumber, int pageSize) Gives collection of Bitbucket organizations (Project/Team).GivesBbRepoGives collection ofBbRepos.Gives user for given userName.static StringgetVersion(String apiUrl) Gives Bitbucket server versionbooleanisEmptyRepo(String orgId, String repoSlug) Checks if its empty/un-initializedstatic booleanisSupportedVersion(String version) Tells whether given version is supported version.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 Details
-
MINIMUM_SUPPORTED_VERSION
-
-
Method Details
-
getVersion
Gives Bitbucket server version- Parameters:
apiUrl- API url of Bitbucket server- Returns:
- version of Bitbucket server
-
getUser
Description copied from class:BitbucketApiGives user for given userName.- Specified by:
getUserin classBitbucketApi- Parameters:
userName- name of user,BbUser.getSlug()- Returns:
BbUser
-
getOrgs
Description copied from class:BitbucketApiGives collection of Bitbucket organizations (Project/Team).- Specified by:
getOrgsin classBitbucketApi- Parameters:
pageNumber- page numberpageSize- number of items in a page- Returns:
- Collection of
BbOrgs
-
getOrg
Description copied from class:BitbucketApiGivesBbOrgfor given project/team name.- Specified by:
getOrgin classBitbucketApi- Parameters:
projectName- Bitbucket project/team keyBbOrg.getKey()- Returns:
BbOrginstance
-
getRepos
Description copied from class:BitbucketApiGives collection ofBbRepos.- Specified by:
getReposin classBitbucketApi- Parameters:
projectKey- Bitbucket project/team keyBbOrg.getKey()pageNumber- page numberpageSize- page size- Returns:
-
getRepo
Description copied from class:BitbucketApiGivesBbRepo- Specified by:
getRepoin classBitbucketApi- Parameters:
orgId- Bitbucket project/team keyBbOrg.getKey()repoSlug- repo slugBbRepo.getSlug()- Returns:
BbRepoinstance
-
getContent
@NonNull public String getContent(@NonNull String orgId, @NonNull String repoSlug, @NonNull String path, @NonNull String commitId) Description copied from class:BitbucketApiGives content of files in Bitbucket. If given path is not available thenServiceException.NotFoundExceptionis thrown.- Specified by:
getContentin 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:BitbucketApiSaves file to Bitbucket.- Specified by:
saveContentin 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:
BbSaveContentResponseon successful save.
-
fileExists
public boolean fileExists(@NonNull String projectKey, @NonNull String repoSlug, @NonNull String path, @NonNull String branch) Description copied from class:BitbucketApiChecks if a file exists in Bitbucket repo.- Specified by:
fileExistsin 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:BitbucketApiGives Bitbucket branch- Specified by:
getBranchin classBitbucketApi- Parameters:
orgId- Bitbucket project/team keyBbOrg.getKey()repoSlug- Repo slugBbRepo.getSlug()branch- branch nameBbBranch.getDisplayId()- Returns:
BbBranchinstance. 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:BitbucketApiCreate branch.- Specified by:
createBranchin classBitbucketApi- Parameters:
orgId- Bitbucket project/team keyBbOrg.getKey()repoSlug- repo slugBbRepo.getSlug()payload- branch payload- Returns:
- Created branch
-
getDefaultBranch
Description copied from class:BitbucketApiGet default branch of a repo.- Specified by:
getDefaultBranchin 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
Description copied from class:BitbucketApiChecks if its empty/un-initialized- Specified by:
isEmptyRepoin classBitbucketApi- Parameters:
orgId- Bitbucket project/team keyBbOrg.getKey()repoSlug- Repo slugBbRepo.getSlug()- Returns:
- true if this is empty or un-initialized repo
-
isSupportedVersion
Tells whether given version is supported version.- Parameters:
version- version of Bitbucket server to test- Returns:
- true if supported false otherwise
- See Also:
-