webhookit是一个极简的命令行版本的gitwebhok,部署容易,非常简单就可以部署一个webhookserver。支持GitHub, GitLab, GitOsc, Gogs, Codig。Pytho2/3都支持。
1.安装pipistallwebhookit
支持Pytho2/3。安装之后,在系统中可以得到两个命令工具:webhookit ad webhookit_cofig。
2.使用运行 webhookit--help 可以得到命令的帮助信息,具体的信息如下:
# webhookit --helpUsage: webhookit [OPTIONS]Optios: -c, --cofig PATH The web hook cofigure file path. -p, --port INTEGER The listeig port of HTTP server. --help Show this message ad exit.运行 webhookit_cofig 可以得到工具配置的模版内容。
运行 webhookit-ccofig.py-p18340 开启一个webhook的http服务器。
3.一个示例下面是一个简单的例子,用来展示如何使用本工具:
# 1. 安装 webhookitpip istall webhookit# 2. 初始化一个配置模版webhookit_cofig > /home/hustcc/webhook-cofigs/cofig4hustcc.py# 3. 更新 cofig4hustcc.py 配置内容vim cofig4hustcc.py# 4. 运行 http serverwebhookit -c cofig4hustcc.py然后在浏览器中打开 https://host:18340 就可以看到下面的一些信息了:
webhook执行的状态;
webhook的URL地址;
webhook的配置信息(隐藏私密信息);
4.配置文件说明# -*- codig: utf-8 -*-'''Created o Mar-03-17 15:14:34@author: hustcc/webhookit'''# This meas:# Whe get a webhook request from `repo_ame` o brach `brach_ame`,# will exec SCRIPT o servers cofig i the array.WEBHOOKIT_CONFIGURE = { # a web hook request ca trigger multiple servers. 'repo_ame/brach_ame': [{ # if exec shell o local server, keep empty. 'HOST': '', # will exec shell o which server. 'PORT': '', # ssh port, default is 22. 'USER': '', # liux user ame 'PWD': '', # user password or private key. # The webhook shell script path. 'SCRIPT': '/home/hustcc/exec_hook_shell.sh' }, ...],...}Pytho变量名 WEBHOOKIT_CONFIGURE 不要去修改。
每个webhook都用仓库的名字和分支名字 'repo_ame/brach_ame' 作为它的键值,每个webhook可以触发一组服务器,这些服务器的配置信息存储在一个数组中。
服务器可以是远程的服务器,也可以是本地机器,如果要触发本机的脚本运行,那么请保持 HOST, PORT, USER, PWD 这些配置为空,或者不存在这些键值。







评论