I want to develop a hook that will automatically merge a branch (always the same one) into the master when smth happens. This should happen because there are some strange diffs when pull requests are opened and we found out that this merging is the solution.
So I am working with the BitBucket Server API and I found the class PullRequestCreateRequest
and the interface PullRequestService
This is what I got atm:
if (MYCONDITION)
{
PullRequestImpl pullRequest = new PullRequestImpl(); //class that implements PullRequestService
PullRequestCreateRequest prCreate = new PullRequestCreateRequest.Builder()
.title("Automatic Merge Branch Foo Into Master")
.description("blablabla")
.repository(request.getRepository()) //from head of the method
//.fromBranch("MyBranch") HELP pls
.toBranchId("master")
.build();
pullRequest.create(prCreate);
pullRequest.merge(prCreate);
}
My Problem is, that I don't know how to specify my source branch. I searched in the Doc, but just found some RefIds, etc. Has someone an idea?
Btw: I create the PR first because it's not allowed to merge directly into the master and I can't change this.