Class BitbucketApiClient
java.lang.Object
io.jenkins.plugins.explain_error.autofix.scm.BitbucketApiClient
- All Implemented Interfaces:
ScmApiClient
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAtomically commits multiple file changes to the given branch.voidcreateBranch(String branchName, String fromBranch) Creates a new branch from the given base branch.createPullRequest(String title, String body, String headBranch, String baseBranch, boolean draft) Creates a pull request and returns the created PR.voiddeleteBranch(String branchName) Deletes a branch (for cleanup/rollback).Returns the default branch name (e.g., "main", "master").getFileContent(String filePath, String branch) Returns the current file content as a UTF-8 string, or null if the file does not exist.voidValidates that the token has write access to the repository.
-
Constructor Details
-
BitbucketApiClient
-
-
Method Details
-
getDefaultBranch
Description copied from interface:ScmApiClientReturns the default branch name (e.g., "main", "master").- Specified by:
getDefaultBranchin interfaceScmApiClient- Returns:
- the default branch name
- Throws:
IOException- if the API call fails
-
validateWriteAccess
Description copied from interface:ScmApiClientValidates that the token has write access to the repository.- Specified by:
validateWriteAccessin interfaceScmApiClient- Throws:
IOException- with a clear message if the token does not have push/write access
-
createBranch
Description copied from interface:ScmApiClientCreates a new branch from the given base branch.- Specified by:
createBranchin interfaceScmApiClient- Parameters:
branchName- the name of the new branchfromBranch- the branch to create from- Throws:
IOException- if the API call fails
-
getFileContent
Description copied from interface:ScmApiClientReturns the current file content as a UTF-8 string, or null if the file does not exist.- Specified by:
getFileContentin interfaceScmApiClient- Parameters:
filePath- the file path relative to repository rootbranch- 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 IOExceptionDescription copied from interface:ScmApiClientAtomically commits multiple file changes to the given branch.- Specified by:
commitFilesin interfaceScmApiClient- Parameters:
branchName- the branch to commit tocommitMessage- the commit messagefileContents- 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:ScmApiClientCreates a pull request and returns the created PR.- Specified by:
createPullRequestin interfaceScmApiClient- Parameters:
title- the pull request titlebody- the pull request description bodyheadBranch- the source branchbaseBranch- the target branchdraft- whether to create as a draft PR- Returns:
- the created PullRequest
- Throws:
IOException- if the API call fails
-
deleteBranch
Description copied from interface:ScmApiClientDeletes a branch (for cleanup/rollback).- Specified by:
deleteBranchin interfaceScmApiClient- Parameters:
branchName- the branch to delete- Throws:
IOException- if the API call fails
-