Skip to content

This repository contains a Python Flask application that accepts webhooks from Ansible Tower, BitBucket, and anything else, based on: https://github.com/cvitter/mattermost-bitbucket-bridge.git

License

Notifications You must be signed in to change notification settings

pnorms/mattermost-bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Webhook Bridges for Mattermost

This repository is contains a Python Flask application that accepts webhooks from [Any Source] and forwards them to the specified channel in a Mattermost server via an incoming webhook, pretty heavily modified version of: https://github.com/cvitter/mattermost-bitbucket-bridge.git

The bridge application supports job notifications and generic body notifications:

Supported Ansible Tower Events

The following events are supported and tested in the current version of this application:

  • Job success
  • Job failure
  • Test notification

Supported Bitbucket Events

The following events are supported and tested in the current version of this application:

  • Pull request comment added
  • Pull request comment deleted
  • Pull request comment edited
  • Pull request declined
  • Pull request deleted
  • Pull request merged
  • Pull request modified
  • Pull request opened
  • Repository commit comment added
  • Repository commit comment deleted
  • Repository commit comment edited
  • Repository forked
  • Repository refs updated

Setup the Flask Application

The following steps

  1. Log into the machine that will host the Python Flask application;
  2. Clone this repository to your machine: git clone https://github.com/pnorms/mattermost-bridge.git;
  3. Edit config.json to update the following fields as needed:
    • Application host address and port (generally debug should be left set to false;
    • Mattermost server_url and the user name or icon to override the webhook with if desired;
    • And the base url of your Ansible Tower server.
  4. Run the Flask application:
sudo python base.py >> base.log 2>&1 &

Configure Mattermost

To use this application you will need to create one or more Incoming Webhooks in Mattermost. These incoming webhooks will be the endpoints that the application will post the events received from Ansible Tower. Webhooks are created by navigating to Integrations in the Main Menu, clicking on Incoming Webhooks, and clicking on Add Incoming Webhook. After creating the incoming webhook you will need to copy the webhook's code at the end of its URL which will be needed when configuring the webhook in Ansible Tower.

Note: You can have all Ansible Tower events post to a single webhook or, or setup incoming webhooks in Mattermost for each Ansible Tower repository.

Configure Ansible Tower

Within Ansible Tower, notification webhooks are configured and managed at a global level. From settings and within notifications click Add: Make the name something reasonable to MatterMost: Ansible, Type will be webhook and enter your personal Target URL, using the details from MM integration. The URL will look like:

http://flask-application-url:port/hooks/[hookcode]

Note: The hook code is the unique hook identifier generated by Mattermost and is found at the end of your Mattermost's incoming webhook URL, ex: https://mymattermostserver.com/hooks/5iz1k8j8rewrjyu3anbw4u66qe.

Then select the Repository and Pull request events you want to be notified about and click on Create to create the webhook.

Configure Bitbucket

Within Bitbucket webhooks are configured and managed at the individual repository level. From within a repository click on the Repository Settings icon (cog) in the left hand side bar and then click on Webhooks under repository settings. To create a new webhook click on the Create webhook button. In the Create webhook form fill in the new webhook's Name and URL. The URL will look like:

Docker Installation

  1. Build the docker image (replace DOCKER_IMAGE_NAME with your name of choice):
  • docker build -t DOCKER_IMAGE_NAME .
  • docker pull DOCKER_IMAGE_NAME
  1. And run the docker image: docker run -d -p 8080:8080 DOCKER_IMAGE_NAME

HELM!

  1. Run helm package mattermost-bridges-dev
  2. Deploy the package to your repository
  3. Launch the item from your kub connected repo

Make this Project Better (Questions, Feedback, Pull Requests Etc.)

Help! If you like this project and want to make it even more awesome please contribute your ideas, code, etc.

If you have any questions, feedback, suggestions, etc. please submit them via issues here: https://github.com/pnorms/mattermost-bridge/issues

If you find errors please feel to submit pull requests. Any help in improving this resource is appreciated!

License

The content in this repository is Open Source material released under the MIT License. Please see the LICENSE file for full license details.

Disclaimer

The code in this repository is not sponsored or supported by Mattermost, Inc.

Authors

Original Code Largely From

Please submit Issues and/or Pull Requests.

About

This repository contains a Python Flask application that accepts webhooks from Ansible Tower, BitBucket, and anything else, based on: https://github.com/cvitter/mattermost-bitbucket-bridge.git

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published