Rate this page:
Deprecated in 5.0
The post-receive module type has been deprecated in Bitbucket Server 5.0 and will be removed in 6.0. Please use the repository hook module type instead. More details can be found in the Repository Hooks and Merge Checks Guide.
Post-receive hooks are similar to pre-receive-hooks except that the push cannot be cancelled. They are useful for outputting messages to the client. If no message is required consider listening for RepositoryPushEvent instead.
Note This hook module is enabled across all repositories.
Name | Required | Description | Default |
---|---|---|---|
key | Yes | The identifier of the plugin module. This key must be unique within the plugin where it is defined. | N/A |
class | Yes | The fully qualified Java class name of the hook. This class must implement com.atlassian.bitbucket.hook.PostReceiveHook . | N/A |
name | The human-readable name of the plugin module. I.e. the human-readable name of the hook. | N/A | |
weight | The (integer) weight of the plugin module. Hooks with a higher weight will be processed later. It should almost never be necessary to set this. Your hook implementation should not rely on a particular order for it to function correctly as the absolute ordering also depends on the weight set on other hooks. | 1000 |
Name | Required | Description | Default |
---|---|---|---|
description | The description of the plugin module. The 'key' attribute can be specified to declare a localisation key for the value instead of text in the element body. I.e. the description of the servlet. | N/A |
Here is an example atlassian-plugin.xml
file containing a single merge check:
1 2<atlassian-plugin name="My Merge Request Check" key="example.plugin.preceive" plugins-version="2"> <plugin-info> <description>A basic component import module test</description> <vendor name="My Company" url="http://www.mycompany.com"/> <version>1.0</version> </plugin-info> <post-receive-hook key="myPostReceiveHook" name="Show some example" class="com.mycompany.example.plugin.myhook.MyPostReceiveHook"> <description>A post-receive hook example that thanks the user for pushing</description> </post-receive-hook> </atlassian-plugin>
And the corresponding hook:
1 2package com.mycompany.example.plugin.myhook; import com.atlassian.bitbucket.hook.HookResponse; import com.atlassian.bitbucket.hook.PostReceiveHook; public class MyPostReceiveHook implements PostReceiveHook { @Override public void onReceive(Repository repository, Collection<RefChange> refChanges, HookResponse hookResponse) { hookResponse.out().println("Thank you for pushing to Bitbucket Server"); } }
Rate this page: