# Stash Latest (2.9) : Using repository hooks

Added by pwatson , edited by pwatson on Nov 07, 2013

Hooks in Stash provide a way to customise a team's workflow and integrate with other systems. Stash currently supports two types of hooks, pre and post-receive.

On this page:

## Managing hooks

Administrators can see the hooks that are available in Stash by going to Settings > Hooks for a Stash repository. Once installed, hooks are available across all repositories in a Stash instance, but are enabled separately on each repository in a project.

Click the 'pen' icon beside the name of a hook to edit configuration details for the hook.

Stash currently ships with the following hooks:

- Reject Force Push – block all Git force pushes (`git push -- force`).
- HipChat Push Notifications – send a message to a HipChat room when someone pushes to the repository.

### Pre-receive hooks

The first hook to run when handling a push from a client is the pre-receive hook. It can reject pushes to the repository if certain conditions are not fulfilled. You can use this hook to prevent force pushes to the repository or check whether all commits contain a valid JIRA issue key.

### Post-receive hooks

The post-receive hook runs after the commits have been processed and can be used to update other services or notify users. For example a post-receive hook can be used to send a message to a chat server or notify a continuous integration server of the newly pushed changes.

## Getting hooks from the Atlassian Marketplace

A number of hooks are available from the Atlassian Marketplace. You can find and install these from within Stash – simply use the Add hook button on the hooks settings page to view available hooks from the marketplace. See Managing add-ons for details.

## Creating your own hooks

Developers can write receive hook plugins for Stash using a simple API that provides a simple way to create a configuration interface, and stores the hook's configuration settings on a per-repository basis.

For information about how to write your own hooks please see the Stash developer docs.

In particular, these pages will be helpful:

- Repository hooks
- Repository hook plugin module

## Learn more about Git hooks

Hooks in Stash are executed on the server, but Git itself also provides support for client-side hooks meant for client operations such as committing and merging. Learn more about Git hooks in the Git documentation.

Note: Git post-receive hooks won't be triggered after a pull request merge. The mechanism that performs the pull request merge is actually based on a `git fetch` into the repository, which doesn't trigger Git post-receive hooks. If you would like to trigger functionality based on a pull request merge, you should write a post-receive repository hook.

## Attachments:

023.png (image/png)
STASH22_hook_config.png (image/png)
STASH22_hook_config.png (image/png)
STASH22_hook_config.png (image/png)
023.png (image/png)
STASH24_repo_hooks.png (image/png)
STASH24_repo_hooks.png (image/png)
STASH24_repo_hooks.png (image/png)
023.png (image/png)
STASH22_hook_config.png (image/png)