自动部署项目
https://github.com/olipo186/Git-Auto-Deploy
http://olipo186.github.io/Git-Auto-Deploy/
Git-Auto-Deploy包含一个小的HTTP服务器,它监听从GitHub,GitLab或Bitbucket服务器发送的Web hook请求,此应用程序允许您在每次将新提交推送到存储库时连续自动部署项目
它是如何工作的?
当提交被推送到你的Git仓库,Git服务器会通过发送一个带有JSON主体的HTTP POST请求到一个预先配置的URL(你的主机:8001)来通知Git-Auto-Deploy。
JSON主体包含有关存储库和触发请求的事件的详细信息。 Git-Auto-Deploy解析和验证请求,如果一切顺利,它会发出一个git pull
此外,Git-Auto-Deploy可以配置为在每次成功执行git pull时执行shell命令,可以用来触发自定义构建操作或测试脚本
开始
您可以通过多种方式安装Git-Auto-Deploy。以下是最常见的方法的说明。
Install from PPA (recommended for ubuntu systems)
Using Debian? Have a look at this answer for instructions.
Add our PPA repository.
sudo apt-get install software-properties-common sudo add-apt-repository ppa:olipo186/git-auto-deploy sudo apt-get update
Install Git-Auto-Deploy using apt.
sudo apt-get install git-auto-deploy
Modify the configuration file to match your project setup. Read more about the configuration options.
nano /etc/git-auto-deploy.conf.json
Optional: Copy any private SSH key you wish to use to the home directory of GAD.
sudo cp /path/to/id_rsa /etc/git-auto-deploy/.ssh/ sudo chown -R git-auto-deploy:git-auto-deploy /etc/git-auto-deploy
Start Git-Auto-Deploy and check it's status.
service git-auto-deploy start service git-auto-deploy status
Install from repository (recommended for other systems)
When installing Git-Auto-Deploy from the repository, you'll need to make sure that Python (tested on version 2.7) and Git (tested on version 2.5.0) is installed on your system.
Clone the repository.
git clone https://github.com/olipo186/Git-Auto-Deploy.git
Install the dependencies with pip, a package manager for Python, by running the following command.
sudo pip install -r requirements.txt
If you don't have pip installed, try installing it by running this from the command line:
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
Copy of the sample config and modify it. Read more about the configuration options. Make sure that pidfilepath is writable for the user running the script, as well as all paths configured for your repositories. 复制配置文件更改它
cd Git-Auto-Deploy cp config.json.sample config.json
Start Git-Auto-Deploy manually using; 手动启动方式
python gitautodeploy --config config.json
To start Git-Auto-Deploy automatically on boot, open crontab in edit mode using crontab -e and add the entry below. crontab -e 编辑定时任务
@reboot /usr/bin/python /path/to/Git-Auto-Deploy/gitautodeploy --daemon-mode --quiet --config /path/to/git-auto-deploy.conf.json
You can also configure Git-Auto-Deploy to start on boot using a init.d-script (for Debian and Sys-V like init systems) or a service for systemd. Read more about starting Git-Auto-Deploy automatically using init.d or systemd.
Install and run GAD under Windows 在windows下安装
GAD runs under Windows, but requires some requisites.
- Install Python 2.7 using the Windows installer.
- Verify that Python is added to your system PATH. Make sure
C:\Python27andC:\Python27\Scriptsis part of the PATH system environment variable. - Install pip using the
get-pip.pyscript - Install Git using the official Git build for Windows
- Verify that Git is added to your system PATH. Make sure that
C:\Program Files\Git\cmdis added (should have been added automatically by the installer) as well asC:\Program Files\Git\bin(not added by default). - Continue with the above instructions for installing GAD from the repository
Alternative installation methods
Download and install Install using pip, a package manager for Python, by running the following command. # pip install git-auto-deploy If you don't have pip installed, try installing it by running this from the command line: # curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python Or, you can download the source code (ZIP) for Git-Auto-Deploy and then run: # python setup.py install You may need to run the above commands with sudo. Once Git-Auto-Deploy has been installed as a python module, it can be started using the executable git-auto-deploy. During installation with pip, the executable is usually installed in /usr/local/bin/git-auto-deploy. This can vary depending on platform. Configuration Copy the content of config.json.sample and save it anywhere you like, for example ~/git-auto-deploy.conf.json. Modify it to match your project setup. Read more about the configuration options. Running the application Run the application using the executable git-auto-deploy which has been provided by pip. Provide the path to your configuration file as a command line argument. # git-auto-deploy --config ~/git-auto-deploy.conf.json Start automatically on boot using crontab The easiest way to configure your system to automatically start Git-Auto-Deploy after a reboot is using crontab. Open crontab in edit mode using crontab -e and add the entry below. When installing with pip, the executable git-auto-deploy is usually installed in /usr/local/bin/git-auto-deploy. It is a good idea to verify the path to git-auto-deploy before adding the entry below. # crontab -e # @reboot /usr/local/bin/git-auto-deploy --daemon-mode --quiet --config /path/to/git-auto-deploy.conf.json
Start automatically on boot Git-Auto-Deploy can be automatically started at boot time using various techniques. Below you'll find a couple of suggested approaches with instructions. The following instructions assumes that you are running Git-Auto-Deploy from a clone of this repository. In such a case, Git-Auto-Deploy is started by invoking python and referencing the gitautodeploy python module which is found in the cloned repository. Such a command can look like python /path/to/Git-Auto-Deploy/gitautodeploy --daemon-mode. If you have used any of the alternative installation methods (install with pip or as a debian package), you will instead start Git-Auto-Deploy using a installed executable. Git-Auto-Deploy would then be started using a command like git-auto-deploy --daemon-mode instead. If you have installed Git-Auto-Deploy in this way, you will need to modify the paths and commands used in the instructions below. Crontab The easiest way to configure your system to automatically start Git-Auto-Deploy after a reboot is using crontab. Open crontab in edit mode using crontab -e and add the following: @reboot /usr/bin/python /path/to/Git-Auto-Deploy/gitautodeploy --daemon-mode --quiet Debian and Sys-V like init system. Copy the sample init script into /etc/init.d/ and make it executable. cp platforms/linux/initfiles/debianLSBInitScripts/git-auto-deploy /etc/init.d/ chmod 755 /etc/init.d/git-auto-deploy Important: The init script assumes that you have Git-Auto-Deploy installed in /opt/Git-Auto-Deploy/ and that the pidfilepath config option is set to /var/run/git-auto-deploy.pid. If this is not the case, edit the git-auto-deploy init script and modify DAEMON, PWD and PIDFILE. Important: The init script will run GAD as the root user by default, which is convenient but not secure. The recommended way to run GAD is to set up a separate user and modify the init script to run GAD as that user. When running GAD as a user other than root, you will need to make sure that the correct permissions are set on all directories and files that GAD requires access to (such as the path specified in the variable PIDFILE and LOGFIE in the init script). Now you need to add the correct symbolic link to your specific runlevel dir to get the script executed on each start up. On Debian_Sys-V just do; update-rc.d git-auto-deploy defaults Fire it up and verify; service git-auto-deploy start service git-auto-deploy status Systemd Copy the sample systemd service file git-auto-deploy.service into /etc/systemd/system; cp platforms/linux/initfiles/systemd/git-auto-deploy.service /etc/systemd/system Create the user and group specified in git-auto-deploy.service (www-data) if those do not exist already. useradd -U www-data This init script assumes that you have Git-Auto-Deploy installed in /opt/Git-Auto-Deploy/. If this is not the case, edit the git-auto-deploy.service service file and modify ExecStart and WorkingDirectory. Now, reload daemons and fire ut up; systemctl daemon-reload systemctl start git-auto-deploy Make is start automatically on system boot; systemctl enable gitautodeploy

浙公网安备 33010602011771号