天天看点

gogs结合git-webhook自动部署

1.安装依赖

<code>yum -y </code><code>install</code> <code>python-devel libxslt-devel libffi-devel openssl-devel</code>

2.编译安装python2.7和pip

<code>tar</code> <code>-xf Python-2.7.5.</code><code>tar</code><code>.gz</code>

<code>cd</code> <code>Python-2.7.5</code>

<code>.</code><code>/configure</code> <code>--</code><code>enable</code><code>-shared</code>

<code>make</code> <code>&amp;&amp; </code><code>make</code> <code>install</code>

<code>ln</code> <code>-s </code><code>/usr/local/bin/python</code> <code>/usr/bin/</code>

<code>unzip  setuptools-36.4.0.zip</code>

<code>cd</code> <code>setuptools-36.4.0.0</code>

<code>python setup.py </code><code>install</code>

<code>tar</code> <code>-xf pip-9.0.1.</code><code>tar</code><code>.gz</code>

<code>cd</code> <code>pip-9.0.1</code>

3.安装git-webhook

<code>pip </code><code>install</code> <code>git-webhook</code>

配置git-webhook

<code>gitwebhook  config</code>

<code>OK: init configuration </code><code>file</code> <code>into `</code><code>/root/</code><code>.git-webhook</code><code>/git_webhook_config</code><code>.py`.</code>

4.安装mysql redis

<code>yum -y </code><code>install</code> <code>mysql mysql-server redis</code>

配置redis 密码,启动redis

启动mysql,创建库

<code>CREATE DATABASE IF NOT EXISTS git_webhook default character </code><code>set</code> <code>utf8 COLLATE utf8_general_ci;</code>

授权

<code>grant all privileges on git_webhook.* to dev@</code><code>'localhost'</code> <code>identified by </code><code>'test'</code><code>;</code>

5.配置git-webhook

<code>vim .git-webhook</code><code>/git_webhook_config</code><code>.py</code>

<code>mysql用户名:dev 密码:</code><code>test</code>

<code>DATABASE_URI = </code><code>'mysql+pymysql://dev:[email protected]/git_webhook'</code>

<code>redis密码:</code><code>test</code>

<code>CELERY_BROKER_URL = </code><code>'redis://:[email protected]:6379/0'</code>

<code>CELERY_RESULT_BACKEND = </code><code>'redis://:[email protected]:6379/0'</code>

<code>SOCKET_MESSAGE_QUEUE = </code><code>'redis://:[email protected]:6379/0'</code>

6.初始化git-webhook数据库

<code>gitwebhook createdb</code>

<code>OK: database is initialed.</code>

7.启动

<code>gitwebhook runserver &amp;</code>

<code>wsgi starting up on http:</code><code>//172</code><code>.31.23.92:18340</code>

<code>gitwebhook  celery &amp;  这个是用于异步执行任务</code>

8.添加服务器

<a href="https://s4.51cto.com/wyfs02/M02/06/94/wKiom1m6ScCgyb2SAACAp3lG8qM783.png" target="_blank"></a>

9.配置webhook

<a href="https://s1.51cto.com/wyfs02/M00/06/94/wKiom1m6SdOyhaaiAACTdO9mbG0980.png" target="_blank"></a>

本文转自 shouhou2581314 51CTO博客,原文链接:http://blog.51cto.com/thedream/1965361,如需转载请自行联系原作者