Get Project Branch on Pull Request

bitbucket-server
java

#1

Hello,

I’m writing a plugin that can block a pull request merge.
I am able to extract. the project key, but not the project branch.
This method is where I am making the decision;

    public RepositoryHookResult preUpdate(
            PreRepositoryHookContext context,
            PullRequestMergeHookRequest request
    ) {

How can I request the merging and merged project branch?


#2

Hi @nielshofmans,

I’m assuming you mean pull request branch? Projects don’t have branches.
You are able to get the pull request source branch name off the ‘from ref’:

String sourceBranch = request.getFromRef().getId();

Depending on what you want to do with it you may also want the display id.

Hope this helps, let me know if you have any further questions.
Kristy