An error occurred while executing the git command automatically deployed using gitHOOK.

Source: Internet
Author: User
On git @ OSC, use the PUSH hook to access the automatically deployed PHP file under the project through URL every time you push {code ...} after each push. text does have a record, but the code is not updated. You have to manually gitpull it every time. How can this be done? On git @ OSC, use the PUSH hook to access the automatically deployed PHP file under the project through the URL each time you push


  Password! = "Xxxxxx") die ("ERROR! "); // Determine the password $ fp = fopen (". /log.txt ", 'A'); $ lastcommit = $ js-> push_data-> commits [count ($ js-> push_data-> commits)-1]; // obtain the final commitif (strstr ($ lastcommit-> message, "release") // This indicates that if the final commit contains "release", it is automatically released. {Exec ('CD/home/xxx/'); // enter the directory exec ("git pull origin master"); // perform git pulling, the premise is that sshfwrite ($ fp ,"!!! ". Date ('Y-m-d H: I: s '). "\ t ". $ lastcommit-> message. "\ t ". $ lastcommit-> author-> name. "\ t ". "Y ". "\ n"); // record} else {fwrite ($ fp, date ('Y-m-d H: I: s '). "\ t ". $ lastcommit-> message. "\ t ". $ lastcommit-> author-> name. "\ t ". "N ". "\ n ");}

After each push, the log. text in the project does have a record, but the code is not updated. You still have to manually run git pull every time. How can this be done?

Reply content:

On git @ OSC, use the PUSH hook to access the automatically deployed PHP file under the project through the URL each time you push


  Password! = "Xxxxxx") die ("ERROR! "); // Determine the password $ fp = fopen (". /log.txt ", 'A'); $ lastcommit = $ js-> push_data-> commits [count ($ js-> push_data-> commits)-1]; // obtain the final commitif (strstr ($ lastcommit-> message, "release") // This indicates that if the final commit contains "release", it is automatically released. {Exec ('CD/home/xxx/'); // enter the directory exec ("git pull origin master"); // perform git pulling, the premise is that sshfwrite ($ fp ,"!!! ". Date ('Y-m-d H: I: s '). "\ t ". $ lastcommit-> message. "\ t ". $ lastcommit-> author-> name. "\ t ". "Y ". "\ n"); // record} else {fwrite ($ fp, date ('Y-m-d H: I: s '). "\ t ". $ lastcommit-> message. "\ t ". $ lastcommit-> author-> name. "\ t ". "N ". "\ n ");}

After each push, the log. text in the project does have a record, but the code is not updated. You still have to manually run git pull every time. How can this be done?

Exec ('CD/home/xxx/'); // enter the directory exec ("git pull origin master"); // execute git pulling, provided that ssh is used

Write it together in an exec file. cd will not modify the directory where the parent process is located. In addition, it is best to redirect the output to the file for troubleshooting.

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.