Gitlat Web Hooks App

Source: Internet
Author: User

Gitlab similar to GitHub, the library created with GitHub must be a public library, which is difficult for some privacy files, so you can use Gitlab to build your own private github.


This article is mainly about how to use the Web-hooks provided by Gitlab to realize the automatic updating of the repository to the remote repository;


1. First you need to install the lamp or LNMP environment in a remote git repository server (this is where you install lamp directly with Yum);

Yum install-y httpd mysql mysql-libs php php-mysql mysql-server php-bcmath php-gd php-mbstring

2. Write a user-triggered script

Cat/var/www/html/update.php<?php//git Warehouse Directory $www_folder = "/home/apache/baby";//Execute command echo shell_exec ("CD $www _ Folder && git pull 2>&1 ");? >

3. Place the update.php in the Apache web directory so that it can be accessed by the browser;

because executing the update.php script requires the permission of the Apache startup user, the following actions are used by Apache users;

4. Create key (login Apache user)

Apache user country is created automatically when Yum installs httpd, so the default is no login permission and home directory, need to change to the following:

grep ' Apache '/etc/passwd apache:x:48:48:apache:/home/apache:/bin/bash
#修改好后, login Apachesu apache# Create a secret key ssh-keygen-t rsa-c "[email protected]" #把apache用户目录下的. Ssh/id_rsa.pub content to SSH to Gitlab users Keys,

Copy the. Ssh/id_rsa.pub content from the Apache user directory to the SSH Keys in the Gitlab user,

5. Clone a user's repository to a local

git clone [email protected]:username/baby#gitlab.com:gitlab domain name (access link) #username: The name of the repository #baby:gitlab the user name

6. Testing

You can now submit a merge request using another user, and then the master user accepts the merge

Then login to Apache server to see if there is automatic synchronization;


This method is only triggered when merging other branches into master Master branch;

This article from the "Shallow faint" blog, reproduced please contact the author!

Gitlat Web Hooks App

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.