reconquest / atlassian-external-hooks

External Hooks plugin for Atlassian Bitbucket
https://external-hooks.reconquest.io
Other
45 stars 37 forks source link

RFE: Support for MergeHookRequest #120

Open nickbroon opened 3 years ago

nickbroon commented 3 years ago

As well as the existing support for RepositoryPushHookRequest and PullRequestMergeHookRequest adding support for MergeHookRequest so that external scripts can be called when thing like automatic branch merging is configured.

https://developer.atlassian.com/server/bitbucket/how-tos/hooks-merge-checks-guide/#choosing-hook-trigger-s-

kovetskiy commented 3 years ago

@nickbroon Hi, this is already supported since you can configure Triggers in the Bitbucket admin panel.

Doc: https://external-hooks.reconquest.io/docs/triggers/ Screenshot: image

This way a merge check will be called twice, but the calls will have different environment variables.

Let's say I merge to release branch and expect to see my changes in development branch too:

Hooks triggered by pull requests have:

BB_HOOK_TRIGGER_ID=pull-request-merge
BB_FROM_REF=source-branch
BB_TO_REF=release-branch

Hooks triggered by automatic merge have:

BB_HOOK_TRIGGER_ID=merge
BB_FROM_REF=release-branch
No BB_PULL_REQUEST_* variables will be available
BB_TO_REF=development-branch

Also, BB_*_HASH variables will have different values. Other variables will have the same value.

BB_IS_DRY_RUN will be false.

Let me know if it works for you or no.

dcasella commented 2 years ago

Hi @kovetskiy, does enabling the Internal Merge Event under Post-receive Triggers help with triggering a post-receive hook after an automatic merge is performed by Bitbucket? 2021-10-29 15_35_40-Administration - Bitbucket

Our workflow could be simplified as follows:

  1. master branch 1.1. feature/X created from master 1.2. release/Y created from master
  2. feature/X merged to release/Y -> Bitbucket automatic merge from release/Y to master
  3. Scripted merge (using this plugin) from master to develop

At this moment, even though the Internal Merge Event under Post-receive Triggers is enabled (as seen in the screenshot above) no event is received by the post-receive hook script. Normal commit or merge events, not done by Bitbucket automatic merge, are received as expected.

Thanks in advance.