Class PullRequestMergedEvent

All Implemented Interfaces:
RepositoryRefsChangedEvent, Serializable

@AsynchronousPreferred public class PullRequestMergedEvent extends PullRequestEvent implements RepositoryRefsChangedEvent
Event raised when a pull request is merged via the web UI or REST, or when a remote merge is detected.

If the pull request was merged by the system, the commit resulting from the merge (which may or may not be a literal merge commit, depending on the configured merge strategy) will be included. Otherwise, if the pull request was merged remotely, meaning a commit which is a descendant of the from ref was pushed to the to ref, the commit will not be provided.

Listeners that are interested in all repository changes (and not just pull request merges) should listen for RepositoryRefsChangedEvents.

See Also:
  • Constructor Details

    • PullRequestMergedEvent

      public PullRequestMergedEvent(@Nonnull Object source, @Nonnull PullRequest pullRequest)
      Constructs a new PullRequestMergedEvent. This is a convenience constructor for remotely-merged pull requests, where the merge commit is not known.
      Parameters:
      source - the entity raising the event
      pullRequest - the pull request that was merged
    • PullRequestMergedEvent

      public PullRequestMergedEvent(@Nonnull Object source, @Nonnull PullRequest pullRequest, @Nullable MinimalCommit commit, @Nullable String message)
      Constructs a new PullRequestMergedEvent. The merge commit should be provided if the pull request was merged by the system, and should be left null if the merge was pushed by a user.
      Parameters:
      source - the entity raising the event
      pullRequest - the pull request that was merged
      commit - the commit that resulted from the merging the pull request via the web UI or REST, which may by null if the pull request was merged remotely and pushed up
      message - the commit message, which may be null
      Since:
      8.14
    • PullRequestMergedEvent

      public PullRequestMergedEvent(@Nonnull Object source, @Nonnull PullRequest pullRequest, @Nullable MinimalCommit commit, @Nullable String message, @Nullable String strategyId, boolean autoMerge)
      Constructs a new PullRequestMergedEvent. The merge commit should be provided if the pull request was merged by the system, and should be left null if the merge was pushed by a user.
      Parameters:
      source - the entity raising the event
      pullRequest - the pull request that was merged
      commit - the commit that resulted from the merging the pull request via the web UI or REST, which may by null if the pull request was merged remotely and pushed up
      message - the commit message, which may be null
      strategyId - the strategy used to merge the pull request
      autoMerge - true if the pull request was auto-merged by the system on behalf of a user; otherwise false
      Since:
      8.14
  • Method Details

    • getCommit

      @Nullable public MinimalCommit getCommit()
      Returns:
      the merge commit, which may be null if the pull request was merged remotely
    • getMessage

      @Nullable public String getMessage()
      Returns:
      the proposed commit message, which may be null
    • getRefChanges

      @Nonnull public Collection<RefChange> getRefChanges()
      Description copied from interface: RepositoryRefsChangedEvent
      Retrieves a collection of the changed refs.

      Note: While the returned collection will never be null, it may be empty. For example, a remotely merged pull request will have an empty set of changes.

      Specified by:
      getRefChanges in interface RepositoryRefsChangedEvent
      Returns:
      a collection of updated refs which may be empty, if the pull request was merged remotely, or contain a single updated ref for the pull request's target branch, if the pull request was merged via the web UI or REST
    • getRepository

      @Nonnull public Repository getRepository()
      Description copied from interface: RepositoryRefsChangedEvent
      Retrieves the repository in which refs were changed. All of the changed refs for a single event will always be in the same repository.
      Specified by:
      getRepository in interface RepositoryRefsChangedEvent
      Returns:
      the repository into which the pull request was merged
    • getStrategyId

      @Nullable public String getStrategyId()
      Returns:
      the ID of the strategy used to merge the pull request
      Since:
      4.9
    • isAutoMerge

      public boolean isAutoMerge()
      Returns:
      true if the pull request was auto-merged by the system on behalf of a user; otherwise false
      Since:
      8.14
      See Also:
    • isMergedRemotely

      public boolean isMergedRemotely()
      Returns:
      true if the pull request was merged remotely and pushed up; otherwise, false if the pull request was merged via the web UI or REST