Skip to main content

Tool for handling Git webhooks

Project description

This is a simple tool that will help you handle Git webhooks. Now it supports the following services:

  • BitBucket
  • GitLab

Installation

pip install gwh

Usage cases

If you want to handle any event from any repository:

from gwh import GitWebhook

gwh = GitWebhook()

@gwh.handle()
def event():
    print(gwh.event['repository'])
    print(gwh.event['type'])
    print(gwh.event['affected_branches'])
    print(gwh.event['raw_data'])

If you want to handle push from specific repository:

@gwh.handle(repository="user/repo", types=['push'])
def event():
    if "dev" in gwh.event['affected_branches']:
        print("pushed")

Finally, you need to pass request from your webserver to GitWebhook handler. It will be Flask in this example:

from flask import Flask, request

app = Flask(__name__)

@app.route("/")
def webhook():
    gwh.handle_request(request.headers, request.data)

Feedback

Bug reports, feature requests, pull requests, any feedback, etc. are welcome.

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for gwh, version 0.1.12
Filename, size & hash File type Python version Upload date
gwh-0.1.12.tar.gz (3.8 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page