I want to automatically merge a PR, when the target is the "develop" branch.
How can I do this with script runner?
I have found the script event handlers and the "Auto merge of pull request" event.
However, I do not find the target branch name, nor the source branch name.
In the "Auto merge of pull request" event handler you can add the following condition to only merge for the branch called "develop":
event.pullRequest.toRef.displayId == "develop"
You can change develop to whatever branch name if you want to include other ones to.
For multiple branches you can use:
event.pullRequest.toRef.displayId in ["develop", "feature"]
Apologies for some reason I was thinking this was a merge request. I've updated the example in my answer.
To get around the minimum approvers issue, you could just move to using the script merge check ScriptRunner provides here.
Then your condition for the "Require a number of approvers" merge check can be:
mergeRequest.pullRequest.toRef.displayId != "develop"
Therefore the minimum number of reviewers will only be enforced for those branches that are not being auto merged. In this case anything other than "develop".
Hope this helps and let me know how you get on with that.
During my 17 years as a coach, mentor, and trainer of Agile teams, I’ve participated in hundreds of Agile planning meetings. The end result was a wall of backlog items annotated by an explosion of co...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event