美文网首页
使用git和码云实现代码的自动部署

使用git和码云实现代码的自动部署

作者: 王宣成 | 来源:发表于2020-04-05 18:25 被阅读0次

linux python环境

1、安装 pip install web.py

2、新建hook.py

3、vim hook.py 编辑

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import web
import os

urls = (
    '/', 'index'
)

app = web.application(urls, globals())

class index:
    def POST(self):
        os.system('cd /home/wwwroot/dnmp/www/grazy_saas_dev && git stash  && git pull')
        return "python post hook!"

if __name__ == "__main__":
    app.run()

4、后台运行

nohup python hook.py > out.log &

指定端口 python hook.py 8080

nohup python hook.py 8080 > out.log &

5、访问 http://iphttp://ip:8080

6、配置地址到码云webhook

相关文章

网友评论

      本文标题:使用git和码云实现代码的自动部署

      本文链接:https://www.haomeiwen.com/subject/lscpphtx.html