django驱动的github(和bitbucket)web挂钩
django-github-hook的Python项目详细描述
django开发人员的简单持续集成,形式如下 用于管理github(或bitbucket)post-receive挂钩的django应用程序。
使用Django1.8和1.9在Python2.7、3.4和3.5上进行了测试。
用法
- pip install django-github-hook
- 将github_hook添加到设置中的INSTALLED_APPS。py
- ./manage.py migrate(或./manage.py syncdb)
- 添加例如url(r'^hook/',include('github_hook.urls'))到 url.pyurlpatterns
- 登录Django管理控制台
- 使用以下字段配置钩子:
- name:钩子标识符
- user:回购用户名
- repo:回购名称
- path:要执行的脚本的绝对路径
- 转到GitHub(或BitBucket)上回购的“服务挂钩”设置并添加
webhook/post网址:
- http[s]://[yourwebsite]/hook
- 回购信息将从json负载中读取
- 或者,可以按名称指定特定的钩子:
- http[s]://[yourwebsite]/hook/name
示例
下面的代码片段演示如何使用django的信号机制将webhook连接到方法。 注意,必须在hook对象中将path设置为“send signal”,而不是脚本的绝对路径。
fromgithub_hook.modelsimporthook_signaldefprocessWebhook(sender,**kwargs):forkey,valueinkwargs.iteritems():printkey,valuehook_signal.connect(processWebhook)