Automatically generate and publish GitBook (Nginx) using GitLab + Jenkins in the LAN)
GitBook is installed on the Intranet, so you cannot use the GitBook webpage. Gitbook serve can only show one book, and it is not conducive to long-term maintenance.
Therefore, GitLab, Jenkins, and Nginx are used together with GitBook.
The basic process is as follows: each book is hosted on GitLab as a project. Upon each submission, GitLab triggers Jenkins and Jenkins pulls down the repository content, build and copy gitbook to the Web server (Nginx) directory, and add the read permission. Then, all people in the LAN can access it directly.
The following record Process
First, gitlab, jenkins, gitbook, and nginx are installed on the machine.
Then, grant the sudo permission of the shell program to jinkins.
Edit the/etc/sudoers file
Add
jenkins ALL=(ALL) NOPASSWD:ALL
In this way, jenkins has sudo permission and password-free access.
Then jenkins will install some plug-ins, Git client plugin Git plugin Gitlab Hook Plugin (maybe only the last one? I installed all three at once)
Assume that the IP address of my machine is 192.168.1.2, gitlab is on port 8081, jenkins is on port 8082, nginx is on port 80, and the folder/www/
The following is an example.
/********************* Create a project on gitlab and configure web hook ******** **************************/
Create a new project in gitlab
For example, it is called the Books _ test, and the corresponding url is
http://192.168.1.2:8081/zhuangqiubin/Books_ceshi
Go to Settings in the lower-left corner of the Project page
Select Web Hooks in the left-side navigation pane.
Enter url
http://192.168.1.2:8082/gitlab/build_now
Click Add Web Hook in the lower-left corner.
Create the README. md and SUMMARY. md files on the local machine and submit them to this project.
/******************* Configure jenkins ***************** ***********************************/
Log on to jenkins http: // 192.168.1.2: 8082
Enter the name in the upper left corner, for example, GitBook _ test.
Select to build a free-style Software Project
Click OK to go to detailed settings
Select git for source code management
Enter the Repository URL in the project url, for example
http://192.168.1.2:8081/zhuangqiubin/Books_ceshi.git
In Credentials, click ADD to enter your gitlab username and password.
Are you sure you want to replace none with the username and password you just added
Add Repository. OK.
Add building steps Execute shells
Add the following code (replace the test with the name you want)
Gitbook buildsudo rm-rf/www/books/test sudo cp-a _ book/www/books/test sudo chmod 777/www/books/test
Click clone on the local machine and then push it back to see if the build can be triggered
Then you can edit, submit, and go to the corresponding page, such
Http: // 192.168.1.2/books/test/
View results
In this way, you can use gitlab to manage gitbook. Once submitted, you can build and move it to the www folder for others to access.
For more GitLab tutorials, see the following:
GitLab Installation Guide in Ubuntu 14.04
How to install Gitlab in Ubuntu Server 14.04
Install GitLab in Chinese with CentOS source code
Install GitLab on Ubuntu 12.04
GitLab 5.3 upgrade considerations
Deploy GitLab on CentOS (self-managed Git project repository)
Install GitLab 6.0.2 on RHEL6/CentOS6/ScientificLinux6
CentOS 6.5 GitLab installation tutorial and Related Problems
GitLab details: click here
GitLab: click here
This article permanently updates the link address: