By default, a user can push more content to a pull request even after it has been approved, yet the approvals remain. This can make a mockery of your defined approval process. This handler will remove any approvals when new content is pushed to an existing pull request, if the condition matches. Using the conditions, you could apply this only when the pull request contains some sensitive code, or for less trusted developers.
The default behaviour in Bitbucket is that approvers will NOT be automatically notified in the event of a changed Pull Request. In this scenario, we recommend creating an entirely new listener that listens for the
PullRequestParticipantUnapprovedEvent and for example sends an email to all Reviewers that had already approved the Pull Request. The following code shows a simple way to send an email after an approval has been removed:
Line 23: Only sends an email to the pull request participant for which the approval has been removed.
Line 25: If you want to send an email with plain text content, change the emailTemplate variable and enter
EmailFormat.TEXT.name() instead of
Line 31: Uses the internal ScriptRunner script to send an email.