git - Webhook let deployment automation

We now have a demand, the project package upload to gitlab, or githubafter, the program can automatically deploy without manually update and run the project to the server, how to do? We can use here gitlaband githubthe hooks, the principle is that every time we have to request gitlaband github, They will then access the server to pull the hook according to our configuration, the webhookhook procedure will always be listening on a port request, a but they sent me the receipt of the request, then you know that the user has submitted a request, then we can use webhookto perform deployment script command procedure.

user's guidance

Gitlab way

Download Project

git clone https://github.com/dounine/gitlab-webhook.git

Line 9 to amend its own password file reading position

fs.readFile('/root/issp/gitlab-webhook/password.txt', 'utf8',....

Modify line 65 to execute a shell script location

cmd.get('/root/issp/docker/' + event.mode + '/run.sh',....

run

cd gitlab-webhook && ./start.sh

gitlabConfiguration

URL:http://xxxxx:7777/webhook
Secret Token:password.txt里面的密码

Github way

Download Project

git clone https://github.com/dounine/github-webhook.git

Modify the position of the third row of the password file itself

var secretPassword = 'abc123' //github secret安全密码

Modify Line 7 shell script location

var bash = '/root/xxx/test.sh' //执行的脚本

run

cd github-webhook && ./start.sh

gitlab Configuration

Payload URL:http://xxxxx:7777/webhook
Secret:安全密码

9028759-5619fe0d9edd7a1b.png

Guess you like

Origin blog.csdn.net/weixin_34261415/article/details/90840116