Skip to content

A simple git webhooks server implemented with Python 3. Supports Github, Gitee, Gitlab, and custom sources. Support custom working directory and command for different repositories. Support to install as the Systemd service.

License

Notifications You must be signed in to change notification settings

troytse/git-webhooks-server

Repository files navigation

Simple Git Webhooks Server

README | 中文说明

Table of Contents

Introduction

  • Implemented with Python 3.
  • Supports Github, Gitee, Gitlab, and custom repositories.
  • Support custom working directory and command for different repositories.
  • Support to install as the Systemd service.

Installation

  • Clone or download this repository to any directory.
  • Run ./install.sh to install.
git clone https://github.com/troytse/git-webhooks-server.git
cd git-webhooks-server
./install.sh

install

Uninstallation

cd git-webhooks-server
./install.sh --uninstal

uninstall

Usage

  • Add the following settings to your configuration file:
# match the full name of your repository
[your_name/repository]
# working directory
cwd=/path/to/your/repository
# the command executes on received the notification.
cmd=git fetch --all & git reset --hard origin/master & git pull
  • Restart the service
systemctl restart git-webhooks-server
  • Add webhook in the repository settings.

Github:

github github-success

Gitee:

gitee gitee-success

Gitlab:

gitlab gitlab-success

Custom:

  • for custom webhooks sources, you need to change the configuration file like follows:
[custom]
# used to identify the source
header_name=X-Custom-Header
header_value=Custom-Git-Hookshot
# used to match the secret
header_token=X-Custom-Token
# the path of the repository name in the json request data.
identifier_path=project.path_with_namespace
# only supports text token verification
verify=True
secret=123456
  • Handler accepts POST data types with application/json or application/x-www-form-urlencoded (you can refer to the guide about request in Github / Gitee / Gitlab), data is like this:
{
  "project": {
    "path_with_namespace": "your_name/repository"
  }
}

custom-header custom-body custom-response

Configuration

  • Default configuration file: /usr/local/etc/git-webhooks-server.ini.
  • You can modify it after the installation.
  • A typical configuration file is as follows:
[server]
address=0.0.0.0
port=6789
log_file=/var/log/git-webhooks-server.log

[ssl]
enable=False
key_file=/path/to/key.pem
cert_file=/path/to/cert.pem

[github]
verify=True
secret=123456

[gitee]
verify=True
secret=123456

[gitlab]
verify=True
secret=123456

[custom]
header_name=X-Custom-Header
header_value=Custom-Git-Hookshot
header_token=X-Custom-Token
identifier_path=project.path_with_namespace
verify=True
secret=123456

[your_name/repository]
cwd=/path/to/your/repository
cmd=git fetch --all & git reset --hard origin/master & git pull

[your_name/sample]
cwd=/path/to/sample
cmd=git fetch --all & git reset --hard origin/master & git pull

About

A simple git webhooks server implemented with Python 3. Supports Github, Gitee, Gitlab, and custom sources. Support custom working directory and command for different repositories. Support to install as the Systemd service.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published