/jira-to-slack

Slack / Mattermost Integration for notifying Jira events, ready on Docker, Cloud Run, App Engine and Lambda

Primary LanguageGoApache License 2.0Apache-2.0

jira-to-slack CircleCI

This is a Slack and Mattermost integration for notifying Jira events. It is written in Go and ready on Docker, Cloud Run, App Engine and Lambda.

Examples

Slack

jira-to-slack

Mattermost

jira-to-mattermost

Getting Started

1. Setup Slack/Mattermost

Create an Incoming Webhook on your Slack or Mattermost.

2. Setup Jira

Create a Webhook on your Jira cloud or server. Set the URL of the Webhook as follows:

https://jira-to-slack.appspot.com/?webhook=https://hooks.slack.com/YOUR_HOOK

You can add the following query parameters:

Name Value Default Example
webhook Slack/Mattermost Webhook URL Mandatory https://hooks.slack.com/YOUR_HOOK
username BOT username - JIRA
icon BOT icon emoji or URL - :speech_baloon: or https://.../jira.png
dialect API dialect slack slack or mattermost
debug Dump Jira and Slack messages to console 0 0 or 1

For example,

jira-webhook-setup

You can deploy jira-to-slack to your server as well. See the later section for details.

3. Test notification

Create a ticket on your Jira and a message will be sent to your Slack/Mattermost. You can turn on debug logs by setting the query parameter debug=1.

Deploy to your server

Standalone

Download the latest release and run the command:

./jira-to-slack

It binds port 3000 by default. You can set the port by PORT environment variable.

PORT=8080 ./jira-to-slack

Docker

Run the image.

docker run --rm -p 3000:3000 int128/jira-to-slack

Cloud Run

You can deploy the image gcr.io/jira-to-slack/jira-to-slack to Google Cloud Run. Click the button.

Run on Google Cloud

App Engine

You can deploy the application to Google App Engine.

# Install SDK
brew cask install google-cloud-sdk
gcloud components install app-engine-go

# Run
make -C appengine run

# Deploy
gcloud app deploy --project=jira-to-slack appengine/app.yaml

Lambda

You can deploy the application to AWS Lambda and API Gateway.

# Run
make -C lambda run

# Deploy
make -C lambda deploy SAM_S3_BUCKET_NAME=YOUR_BUCKET_NAME

You need to create a S3 bucket in the same region before deploying.

If you want to deploy the application to AWS Lambda and ALB Target Group, you need to change the request and response types as follows:

sed -i \
  -e s/APIGatewayProxyRequest/ALBTargetGroupRequest/g \
  -e s/APIGatewayProxyResponse/ALBTargetGroupResponse/g \
  lambda/main.go

How it works

Triggers

jira-to-slack sends a message to the Slack channel on the following triggers:

  • Someone created an issue.
  • Someone commented to an issue.
  • Someone assigned an issue.
  • Someone updated summary or description of an issue.
  • Someone deleted an issue.

Mentions

jira-to-slack sends mentions to reporter and assignee of the issue.

If the issue or comment has mentions (Slack style @foo or JIRA style [~foo]), jira-to-slack sends the mentions as well.

Other solutions

JIRA Mattermost Webhook Bridge. Great work. This is almost perfect but notifies many events so it may be noisy.

Mattermost official JIRA Webhook Plugin. This is still beta and in progress. Currently this does not notify comment.

Contribution

This is an open source software licensed under Apache License 2.0. Feel free to open your issues or pull requests.

Development

Start the server:

make
./jira-to-slack

E2E Test

You can send actual payloads of actual Jira events by the following script:

# Slack
SLACK_WEBHOOK="https://hooks.slack.com/xxx&username=JIRA&icon=https://lh3.googleusercontent.com/GkgChJMixx9JAmoUi1majtfpjg1Ra86gZR0GCehJfVcOGQI7Ict_TVafXCtJniVn3R0" ./pkg/formatter/testdata/post_jira_events.sh

# Mattermost
SLACK_WEBHOOK="https://mattermost.example.com/hooks/xxx&username=JIRA&icon=https://lh3.googleusercontent.com/GkgChJMixx9JAmoUi1majtfpjg1Ra86gZR0GCehJfVcOGQI7Ict_TVafXCtJniVn3R0&dialect=mattermost" ./pkg/formatter/testdata/post_jira_events.sh