webhook 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
webhook 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
webhook 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 MIT
开发语言 Python 查看源码 »
操作系统 跨平台
软件类型 开源软件
所属分类 其他
开源组织
地区 国产
投 递 者 南院逍大王
适用人群 未知
收录时间 2017-03-31

软件简介

webhookit 是一个极简的命令行版本的 git webhok,部署容易,非常简单就可以部署一个 webhook server。支持GitHub, GitLab, GitOsc, Gogs, Coding。Python 2 / 3 都支持。

1. 安装

pip install webhookit

支持 Python 2 / 3。安装之后,在系统中可以得到两个命令工具:webhookit and webhookit_config

2. 使用

运行 webhookit --help 可以得到命令的帮助信息,具体的信息如下:

# 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.

运行 webhookit_config 可以得到工具配置的模版内容。

运行 webhookit -c config.py -p 18340 开启一个 webhook 的 http 服务器。

3. 一个示例

下面是一个简单的例子,用来展示如何使用本工具:

# 1. 安装 webhookit
pip install webhookit

# 2. 初始化一个配置模版
webhookit_config > /home/hustcc/webhook-configs/config4hustcc.py

# 3. 更新 config4hustcc.py 配置内容
vim config4hustcc.py

# 4. 运行 http server
webhookit -c config4hustcc.py

然后在浏览器中打开 http://host:18340 就可以看到下面的一些信息了:

  1. webhook 执行的状态;

  2. webhook 的 URL 地址;

  3. webhook 的配置信息(隐藏私密信息);

4. 配置文件说明

# -*- 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'
    }, 
	...],
	...
}

Python 变量名 WEBHOOKIT_CONFIGURE 不要去修改。

每个 webhook 都用仓库的名字和分支名字 'repo_name/branch_name' 作为它的键值,每个 webhook 可以触发一组服务器,这些服务器的配置信息存储在一个数组中。

服务器可以是远程的服务器,也可以是本地机器,如果要触发本机的脚本运行,那么请保持 HOSTPORTUSERPWD 这些配置为空,或者不存在这些键值。

展开阅读全文

代码

的 Gitee 指数为
超过 的项目

评论

点击加入讨论🔥(1) 发布并加入讨论🔥
暂无内容
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
暂无内容
1 评论
6 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部