Class BitbucketApiClient

java.lang.Object
io.jenkins.plugins.explain_error.autofix.scm.BitbucketApiClient
All Implemented Interfaces:
ScmApiClient

public class BitbucketApiClient extends Object implements ScmApiClient
  • Constructor Details

    • BitbucketApiClient

      public BitbucketApiClient(ScmRepo repo)
  • Method Details

    • getDefaultBranch

      public String getDefaultBranch() throws IOException
      Description copied from interface: ScmApiClient
      Returns the default branch name (e.g., "main", "master").
      Specified by:
      getDefaultBranch in interface ScmApiClient
      Returns:
      the default branch name
      Throws:
      IOException - if the API call fails
    • validateWriteAccess

      public void validateWriteAccess() throws IOException
      Description copied from interface: ScmApiClient
      Validates that the token has write access to the repository.
      Specified by:
      validateWriteAccess in interface ScmApiClient
      Throws:
      IOException - with a clear message if the token does not have push/write access
    • createBranch

      public void createBranch(String branchName, String fromBranch) throws IOException
      Description copied from interface: ScmApiClient
      Creates a new branch from the given base branch.
      Specified by:
      createBranch in interface ScmApiClient
      Parameters:
      branchName - the name of the new branch
      fromBranch - the branch to create from
      Throws:
      IOException - if the API call fails
    • getFileContent

      public String getFileContent(String filePath, String branch) throws IOException
      Description copied from interface: ScmApiClient
      Returns the current file content as a UTF-8 string, or null if the file does not exist.
      Specified by:
      getFileContent in interface ScmApiClient
      Parameters:
      filePath - the file path relative to repository root
      branch - the branch to read from
      Returns:
      file content as a string, or null if not found
      Throws:
      IOException - if the API call fails for a reason other than 404
    • commitFiles

      public void commitFiles(String branchName, String commitMessage, Map<String,String> fileContents) throws IOException
      Description copied from interface: ScmApiClient
      Atomically commits multiple file changes to the given branch.
      Specified by:
      commitFiles in interface ScmApiClient
      Parameters:
      branchName - the branch to commit to
      commitMessage - the commit message
      fileContents - map of filePath to new complete file content (not diffs)
      Throws:
      IOException - if the API call fails
    • createPullRequest

      public PullRequest createPullRequest(String title, String body, String headBranch, String baseBranch, boolean draft) throws IOException
      Description copied from interface: ScmApiClient
      Creates a pull request and returns the created PR.
      Specified by:
      createPullRequest in interface ScmApiClient
      Parameters:
      title - the pull request title
      body - the pull request description body
      headBranch - the source branch
      baseBranch - the target branch
      draft - whether to create as a draft PR
      Returns:
      the created PullRequest
      Throws:
      IOException - if the API call fails
    • deleteBranch

      public void deleteBranch(String branchName) throws IOException
      Description copied from interface: ScmApiClient
      Deletes a branch (for cleanup/rollback).
      Specified by:
      deleteBranch in interface ScmApiClient
      Parameters:
      branchName - the branch to delete
      Throws:
      IOException - if the API call fails