Interface AutoMergeService
public interface AutoMergeService
- Since:
- 8.15
- 
Method SummaryModifier and TypeMethodDescriptioncancelAutoMerge(int repositoryId, long pullRequestId, AutoMergeCancelledReason cancelledReason) Cancels the automatic merging of the pull request by the system with a provided reason, and logs the cancellation as apull request activity.getAutoMergeRequest(PullRequest pullRequest) Finds anauto-merge requestfor the given pull request.booleanisSettingEnabledForPullRequest(PullRequest pullRequest) submitAutoMergeRequest(PullRequestMergeRequest pullRequestMergeRequest) Creates an auto-merge request for the provided pull request with all the parameters from the provided merge request, if all the following conditions are met: thesettingis enabled for the repository that the pull request targets auto-merge is not already requested for this pull request there are no merge conflicts on the pull request the pull requestcannot be mergedimmediatelytryAutoMerge(int repositoryId, long pullRequestId) Requests the system to try auto-merging a pull request.
- 
Method Details- 
cancelAutoMerge@Nonnull PullRequest cancelAutoMerge(int repositoryId, long pullRequestId, @Nonnull AutoMergeCancelledReason cancelledReason) Cancels the automatic merging of the pull request by the system with a provided reason, and logs the cancellation as apull request activity. If a pull request was set to auto-merge, and it has not been merged yet, invoking this method will ensure that the system does not try to merge this pull request, and it has to be merged manually. If the pull request is not set to auto-merge this method is a no-op.- Parameters:
- repositoryId- the ID of the repository to which the pull request is supposed to merge
- pullRequestId- the ID of the pull request within the repository
- cancelledReason- the reason the auto-merge request has been cancelled
- Returns:
- The pull request for which the cancellation of auto-merge is requested
- Throws:
- NoSuchPullRequestException- if the pull request is not found
- IllegalPullRequestStateException- if the pull request is currently- lockedfor some other operation.
 
- 
getAutoMergeRequestFinds anauto-merge requestfor the given pull request.- Parameters:
- pullRequest- the pull request for which auto-merge request has to be fetched
- Returns:
- an Optionalcontaining auto-merge request for the pull request, if one exists, otherwiseOptional.empty()
 
- 
isSettingEnabledForPullRequest- Parameters:
- pullRequest- the pull request to check if its target repository has auto-merge settings enabled
- Returns:
- trueif auto-merge is enabled for the repository containing the pull request; otherwise,- falseif it is disabled
- Since:
- 8.15
 
- 
submitAutoMergeRequest@Nonnull PullRequest submitAutoMergeRequest(@Nonnull PullRequestMergeRequest pullRequestMergeRequest) Creates an auto-merge request for the provided pull request with all the parameters from the provided merge request, if all the following conditions are met:- the settingis enabled for the repository that the pull request targets
- auto-merge is not already requested for this pull request
- there are no merge conflicts on the pull request
- the pull request cannot be mergedimmediately
 If the auto-merge request is submitted successfully, the system will merge this pull request on behalf of the user that requested auto-merge once the pull request is ready to merge. If the pull request is already mergeable, it will be merged immediately.- Parameters:
- pullRequestMergeRequest- the parameters to be used to auto-merge the pull request when it is ready to merge
- Returns:
- the updated pull request
- Throws:
- AutoMergeSettingNotEnabledException- if the auto-merge setting is not enabled for this repository
- IllegalPullRequestStateException- if the pull request has merge conflict(s)
 
- the 
- 
tryAutoMergeRequests the system to try auto-merging a pull request. A merge will be attempted if the following conditions are met:- There is a valid auto-merge request associated with the provided pull request. If the request is
     invalid, e.g. because changes have been made to the source branchor the auto-merge request has expired, then the request is cancelled.
- The pull request can be merged. If the pull request cannot be merged, e.g. because it islockeddue to rescoping orhas conflicts with the target branch, then the request is cancelled.
 If both conditions are met, then the merge will be attempted. - Parameters:
- repositoryId- the ID of the repository to which the pull request is supposed to merge
- pullRequestId- the ID of the pull request within the repository
- Returns:
- the result of auto-merge processing
- Throws:
- AutoMergeNotRequestedException- if no auto-merge request is found for the specified pull request
- AutoMergeSettingNotEnabledException- if the auto-merge setting is not enabled for this repository
- NoSuchPullRequestException- if the pull request is not found
- PullRequestMergeVetoedException- if the pull request was vetoed while merging but not during- dry run
 
- There is a valid auto-merge request associated with the provided pull request. If the request is
     invalid, e.g. because changes have been made to the 
 
-