Git----use Webhook for automatic code deployment

Source: Internet
Author: User
Tags webhook

Cause: Often local push to gitee and other online code warehouse, and then log on to the server in the pull, very troublesome, want to lazy how to do? Use Git's webhook to implement!1. Implementation Principle 1.1 Local commit push 1.2 online warehouse monitoring push action, that is, Webhook, Callback URL triggers the pull operation of the server 1.3 server pull Operation 2. Implement step 2.1 local and server install Git (skip) 2.2 yards cloud into the project--management->webhook settings (other principles like git,coding)

URL is the address that you can access on the server, the address is the file for pull command, can be php,python,node and so on, tick push is when the push action trigger this URL, access to the server for the pull operation, tick other is the other action, There is no explanation here. After adding, there will be Test button, suggest code write on test
1 shell_exec (' ls ')
If the file directory is returned, it means that the permission can be executed, the server is LNMP, and then only one line of code (my requirement is automatic pull, all do not do in-depth operations, such as validation, logs, classifications, etc. can be supplemented by their own) through the code can view the callback information, according to information operation
$request = Json_decode (file_get_contentstrue)
Pull action
Echo shell_exec (' CD Your_path && git Pull ')
3. Some pits, if unsuccessful, suggest LL command to check the user permissions generally PHP is a www-data user, using
chown -r:www-chmod -R g+w  Your_path
The main problem is permissions, so it should be OK! Routing something yourself to get it done! Then you can have a happy local push server to pull the ~ hahaha

Git----use Webhook for automatic code deployment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.