If a developer makes a direct push to a branch using a repository's Stash URL, the post-receive hook gets successfully triggered.
However, the same hook doesn't trigger if the developer uses the Merge button after his/her changes are code reviewed.
I thought that since the pull request merge happens server-side, the post-commit hook would be the correct place to have a repository trigger. However, having the repo trigger in both the post-receive and post-commit still didn't work after using the Merge button in a pull request.
Is this a bug? What hooks are called before and after the server-side merge in Stash?
The mechanism that performs the pull request merge is actually based on a git fetch into the repository, which doesn't trigger receive hooks. Unfortunately there are currently no hooks that will be invoked automatically after a merge.
That said, if you want to trigger functionality based on a pull request merge, you can build a Stash plugin that consumes the PullRequestMergedEvent. There is also a java API for implementing commit-hooks in a plugin. If you're unfamiliar with Atlassian plugins, the Atlassian SDK is a good place to start.
I'd also keep an eye on STASH-2521, which tracks improved commit hooks support in Stash and should hit arelease in the near future.
Here's an update on my answer from last year:
Repository hooks implementing AsyncPostReceiveRepositoryHook will be called for both pushes and Pull Request merges. See https://developer.atlassian.com/stash/docs/latest/how-tos/repository-hooks.html for full details.
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
A note to all watchers that we've moved to a new community home... https://community.atlassian.com/t5/Agility/ct-p/agility Please update your notification subscriptions to keep across the ...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs