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:
The following events are supported and tested in the current version of this application:
- Job success
- Job failure
- Test notification
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
The following steps
- Log into the machine that will host the Python Flask application;
- Clone this repository to your machine:
git clone https://github.com/pnorms/mattermost-bridge.git
; - 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.
- Application host address and port (generally debug should be left set to
- Run the Flask application:
sudo python base.py >> base.log 2>&1 &
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.
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.
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:
- Build the docker image (replace
DOCKER_IMAGE_NAME
with your name of choice):
docker build -t DOCKER_IMAGE_NAME .
docker pull DOCKER_IMAGE_NAME
- And run the docker image:
docker run -d -p 8080:8080 DOCKER_IMAGE_NAME
- Run helm package mattermost-bridges-dev
- Deploy the package to your repository
- Launch the item from your kub connected repo
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!
The content in this repository is Open Source material released under the MIT License. Please see the LICENSE file for full license details.
The code in this repository is not sponsored or supported by Mattermost, Inc.
- Author: Patrick Norman
- Author: Craig Vitter
- Project: mattermost-bitbucket-bridge
Please submit Issues and/or Pull Requests.