在github和bitbucket post请求挂钩上运行命令
hooked的Python项目详细描述
对github和bitbucket post请求挂钩运行命令。
安装
您可以在virtualenv中安装hooked(使用virtualenvwrapper和pip):
$ mkvirtualenv hooked (hooked) $ pip install hooked
或者,如果您想提供一些修补程序来连接
$ git clone git@github.com:bbinet/hooked.git $ cd hooked/ $ mkvirtualenv hooked (hooked) $ python setup.py develop
配置
创建一个如下所示的配置文件:
$ cat path/to/config.cfg [server] host = 0.0.0.0 port = 8080 server = cherrypy debug = true [hook-myrepo] repository = myrepo branch = master command = /path/to/script.sh [hook-all] #repository = # will match all repository #branch = # will match all branches command = /path/to/other/script.sh
请注意,[server]部分是可选的,默认值为:
[server] host = localhost port = 8888 server = wsgiref debug = false
运行
通过运行以下命令运行挂接服务器:
(hooked) $ hooked path/to/config.cfg
然后访问http://localhost:8888/,它应该返回当前配置 对于这个钩子服务器。 如果这有效,您就可以配置github和bitbucket post请求web了 挂接到挂接的服务器侦听地址,例如: http://localhost:8888/。
请参见:
- https://confluence.atlassian.com/display/BITBUCKET/POST+hook+management
- https://developer.github.com/webhooks/
您还可以通过get请求手动运行钩子:
- requesting the /hooks/<repo>/<branch> url will run all hooks that match repository=<repo> and branch=<branch>
- requesting the /hook/<hook> url will run the hook which name is <hook>
释放
要制作新版本,请执行以下步骤:
$ vi setup.py # bump version $ git add setup.py $ git commit -m "bump version to X.X.X" $ git tag vX.X.X $ git push --tags $ python setup.py sdist upload
谢谢
感谢hook-server和 githook激发灵感的项目。