3 Star 5 Fork 0

小为 / webhookit

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README
MIT

webhookit

A simple cli tool to create http server for git webhook, GitHub, GitLab, GitOsc, Gogs, Coding are all supported.

LIVE DEMO | 中文说明文档

Latest Stable Version Build Status GitHub GitLab GitOsc Gogs Coding

1. Install

pip install webhookit

Python 2 / 3 are all supported. After install, you can get two commands named webhookit and webhookit_config in your system.

2. Usage

Run webhookit --help to get help content of the command. Help content below:

# webhookit --help
Usage: webhookit [OPTIONS]

Options:
  -c, --config PATH      The web hook configure file path.
  -p, --port INTEGER     The listening port of HTTP server.
  --help                 Show this message and exit.

Run webhookit_config to get the config template strings.

Run webhookit -c config.py -p 18340 to start the http server for git webhook.

3. Example

Here is an simple example to run the webhookit http server.

# 1. install webhookit
pip install webhookit

# 2. initial a webhookit config file
webhookit_config > /home/hustcc/webhook-configs/config4hustcc.py

# 3. update config4hustcc.py with your own config and save
vim config4hustcc.py

# 4. run webhookit http server
webhookit -c config4hustcc.py

Then open http://host:18340 in your browser, can see:

  1. The webhook status.
  2. The webhook url.
  3. The webhook server configures.

4. configure file

# -*- coding: utf-8 -*-
'''
Created on Mar-03-17 15:14:34
@author: hustcc/webhookit
'''

# This means:
# When get a webhook request from `repo_name` on branch `branch_name`,
# will exec SCRIPT on servers config in the array.
WEBHOOKIT_CONFIGURE = {
    # a web hook request can trigger multiple servers.
    'repo_name/branch_name': [{
        # if exec shell on local server, keep empty.
        'HOST': '',  # will exec shell on which server.
        'PORT': '',  # ssh port, default is 22.
        'USER': '',  # linux user name
        'PWD': '',  # user password or private key.

        # The webhook shell script path.
        'SCRIPT': '/home/hustcc/exec_hook_shell.sh'
    }, 
	...],
	...
}

The python var name WEBHOOKIT_CONFIGURE can not be modified.

Each webhook has it's key with format of 'repo_name/branch_name', Each webhook can trigger a group of servers, which is the value of the key.

Server can be remote and local, if local, keep HOST, PORT, USER, PWD be empty.

5. License

MIT@hustcc.

The MIT License (MIT) Copyright (c) 2017 Hust.cc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

:octocat: Simple git webhook cli tool for automation tasks, bind git webhook to action. expand collapse
Python
MIT
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
Python
1
https://gitee.com/hustcc/webhookit.git
git@gitee.com:hustcc/webhookit.git
hustcc
webhookit
webhookit
master

Search