Hello,
I am working on making our pull requests merge automatically if a certain set of conditions are true.
However, I have not been successful yet and therefore kindly ask for your help!
I am using the adaptavist ScriptRunner for Bitbucket version 4.5.2 (Self-hosted Bitbucket).
By testing I have figured out that a merge, triggered from adaptavist ScriptRunner, can only happen if the pull request "conditions" are met.
In my case:
✓ Requires 1 approvers
✓ Requires all tasks to be resolved
✓ Requires a minimum of 1 successful builds
It seems like build status and issue state is not part of the pull request? I do not know if this is true? But I can not find any information about e.g. build statuses in the documentation here: https://developer.atlassian.com/static/javadoc/bitbucket-server/4.5.2/api/reference/com/atlassian/bitbucket/event/pull/package-summary.html
I can make the adaptavist ScriptRunner fire events e.g. in case of approval with the following code:
event.pullRequest.reviewers.count {it.approved} >= 1
However if the tasks are not resolved or there are no successful builds the merge will not happen (This is as it should be!)
But when tasks do get resolved or a successful build comes in I cannot get the adaptavist ScriptRunner to trigger, I have tried with the following code:
event.pullRequest
If my suspicions is true and Bitbucket only handles pull requests events which are defined in git this means that I have no way to check for these events with the adaptavist ScriptRunner right?
Some elegant solution for me would be to make Bitbucket and adaptavist ScriptRunner able to trigger on all events on a pull request, i.e. issue state change in jira, build status from CI, approvals.
Or make a scheduler which checks every 10 seconds if something is ready to be merged.
I have heard about a workaround where the CI server tries to merge the pull requests if the conditions are met, but I think this is a far from optimal solution.
If anymore information is needed feel free to ask!
Anyone have any information or helpful thoughts about how I can get this to work?