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
  • Field Details

    • MINIMUM_SUPPORTED_VERSION

      public static final VersionNumber MINIMUM_SUPPORTED_VERSION
  • Method Details

    • 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 class BitbucketApi
      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 class BitbucketApi
      Parameters:
      pageNumber - page number
      pageSize - number of items in a page
      Returns:
      Collection of BbOrgs
    • getOrg

      @NonNull public BbOrg getOrg(@NonNull String projectName)
      Description copied from class: BitbucketApi
      Gives BbOrg for given project/team name.
      Specified by:
      getOrg in class BitbucketApi
      Parameters:
      projectName - Bitbucket project/team key BbOrg.getKey()
      Returns:
      BbOrg instance
    • getRepos

      @NonNull public BbPage<BbRepo> getRepos(@NonNull String projectKey, int pageNumber, int pageSize)
      Description copied from class: BitbucketApi
      Gives collection of BbRepos.
      Specified by:
      getRepos in class BitbucketApi
      Parameters:
      projectKey - Bitbucket project/team key BbOrg.getKey()
      pageNumber - page number
      pageSize - page size
      Returns:
    • getRepo

      @NonNull public BbRepo getRepo(@NonNull String orgId, @NonNull String repoSlug)
      Description copied from class: BitbucketApi
      Gives BbRepo
      Specified by:
      getRepo in class BitbucketApi
      Parameters:
      orgId - Bitbucket project/team key BbOrg.getKey()
      repoSlug - repo slug BbRepo.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 then ServiceException.NotFoundException is thrown.
      Specified by:
      getContent in class BitbucketApi
      Parameters:
      orgId - Bitbucket project/team key BbOrg.getKey()
      repoSlug - Bitbucket repo slig BbRepo.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 class BitbucketApi
      Parameters:
      projectKey - Bitbucket project/team key BbOrg.getKey()
      repoSlug - Repo slug BbRepo.getSlug()
      path - destination path, e.g. "Jenkinsfile"
      content - file content to save
      commitMessage - commit message
      branch - branch name. If null then implementation should save on default branch
      commitId - 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 class BitbucketApi
      Parameters:
      projectKey - Bitbucket project/team key BbOrg.getKey()
      repoSlug - repo slug BbRepo.getSlug()
      path - path of file, e.g. "Jenkinsfile"
      branch - Bitbucket branch BbBranch.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 class BitbucketApi
      Parameters:
      orgId - Bitbucket project/team key BbOrg.getKey()
      repoSlug - Repo slug BbRepo.getSlug()
      branch - branch name BbBranch.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 class BitbucketApi
      Parameters:
      orgId - Bitbucket project/team key BbOrg.getKey()
      repoSlug - repo slug BbRepo.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 class BitbucketApi
      Parameters:
      orgId - Bitbucket project/team key BbOrg.getKey()
      repoSlug - Repo slug BbRepo.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 class BitbucketApi
      Parameters:
      orgId - Bitbucket project/team key BbOrg.getKey()
      repoSlug - Repo slug BbRepo.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: