Here at Pragmatic Bits, we use Atlassian Stash for git repository management and Slack for team collaboration (Emails? Who reads emails? Email is slow). Slack is great, and has a huge amount of integration points with other tools out of the box already, but we could not find an existing way to configure pull request notifications from Stash to Slack.

There is a cool post-receive hook here which you can use to send slack notifications for git push operations (configuration is done with async external post receive hook plugin for Stash), but this won’t work for pull requests, simply because git has no clue about pull requests, this is an additional feature added by Stash on the server (and on Github :-)).

Because of this, we ended up writing our own Stash plugin to handle both cases:

  • Send slack messages about pull request activity
  • Also send messages about push operations

This way we don’t need to manage a separate hook for push notifications and yet another plugin for the pull requests. Fortunately Stash has a rich server side API and you can subscribe to various server events like the pull requests, repository operations and so on.

Getting and installing the plugin

You can grab the latest release from Github. Download the jar file and install it into your stash instance from the manage addons page.

Configuring the plugin

Slack configuration

You need to create an incoming web hook in Slack. Go to slack home using a web browser, and select Add Integrations. Scroll to the bottom, and select Incoming WebHooks (click on Add). This will generate the hook url.

Stash to Slack plugin configuration

There are two places for the configuration. First is the global setting page that you can access from the Stash admin section page. Here you can enter the generated hook url.

Global config

Now, you have the option to enable notifications on a per repository basis. Go to your repository settings page, select Slack settings and enable pull request and/or push notifications with the check boxes. You can override here the default channel name (which you specified during the webhook setup in Slack), and you can also override the global hook url (in the case you need to send it to a different slack team, for example).

Local repo config

Here is an example screenshot about the push notifications: Example notifications

Happy notifications!