Get Project Branch on Pull Request




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?


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.