[EasyCi] continuous integration delivery, one-click automated deployment system, out of the box

Foreword

  It was an Internet company's java development, due to the company's operation and maintenance personnel the company initially did not move, I'm just more familiar with linux, then set up a server in the company Jenkins, Gitlab, Maven PW, Docker PW, Sonarqube, ELK, FastDFS etc. operation and maintenance of a continuous integration environment.

  It was discovered that after this operation and maintenance also into my hands ...... usually do system development, operation and maintenance but also part-time, some of the front-end or back-end publishing Jenkins are looking for me to create a project, add gitlab hook, add dockerfile files, etc. .

  And so I want to write a simple set of integrated continuous release system. There will be a next EasyCi.

  The purpose EasyCi system development is removed from the remote publishing secret-free landing, pulling gitlab code authentication, manually add gitlab hook, in view of the project's git gitlab address, etc. redundant operation. These operations are completed automatically in the background, the system provides a runtime environment key installation script, automated installation and deployment of the system, out of the box, you only need a few parameters to remote construction project, only supports java project and build vue .

  Easyci system uses B / S structure, using springboot rear frame, the front-end Vue element ui, database using mysql, the running tool is a shell script, using real-time websocket log transmission.

  Because the system independently developed by me, on the front-end development is not very good, the page is relatively simple, only basic functions, features and subsequent pages will be optimized.

system structure

Jenkins System Architecture

Toolchain

Jenkins: integration of various tools, continuous integration, continuous delivery

Gitlab: code hosting library, triggered by gitlab hook Jenkins continuous integration delivery

Maven PW: private warehouse jar package

Docker PW: Private docker mirror repository for remote building

Sonarqube: code review tool

ELK: log phone system, analysis system

Process

1.Jenkins integrated gitlab, maven, docker, sonarqube, install various plug-ins

2. The developers submit code to gitlab, triggering jenkins project url gitlab hook be added to build jenkins

3.jenkins automatic pulling gitlab code for the project, packaged, and then packaged into docker mirror, mirror docker docker submitted to PW

4. Connection Server release needs docker PW mirrored pull to the item, the container running RUN docker 

Add gitlab tag and submit gitlab after 5.Jenkins build the project runs to completion as the basis for future rollback

6.Jenkins fails to build the automatic pulling latest gitlab tag rebuild, rollback, the rollback fails to build again stops

7. Build success or rollback success or failure will be rolled back by sending e-mail alert sendmail linux and additional build log

8. The building code will be uploaded by sonarqube plug sonarqube code review

System of FIG.

 

 

EasyCi System Architecture

Toolchain

EasyCI: easyci system background, call the shell script, the results returned by the interface front-end

EasyCI-UI: easyci system onstage, vue. Call back interface exposes data

Gitlab: code hosting tool, gitlab hook deliver continuous integration trigger easyci

shell script: linux script

Docker PW: Private docker mirror repository for remote building

MySQL: easyci system database

Process

1. Depending on the installation file to install the system, booting the system

2. Access the system first needs to verify gitlab: gitlab the url, user name and password. Construction for selecting items, pull code verification server, automatically add Hook, replacing manual operation.

3. Add the remote Publisher: server ip, port, user name and password. Log in automatically in the background to complete the free secret between the server for remote publishing project, view the server container and container various operations.

4. Deploy: Select items url, input docker container port mapping relationship, select the project type, enter the recipient's mailbox, select the deployment server, only two things you need to enter to complete the deployment.

5. Click deployed, will pop up a window display system deployment log.

6. Deploy will automatically add the interface url easyci the hook to hook the deployment project for the construction of an automatic trigger.

7. deployed automatically send a message to a recipient's mailbox, display build results, time to build, build the project, build log.

gitlab 8. Follow developers submit code to the project, it will trigger gitlab the hook call easyci interface information before deploying queries to automatically deploy, implement continuous integration.

9. page display container easyci the machine running the container and add the remote server is running, and turn off auto-refresh support data

10. You can choose to add a remote server, view the list of servers container

11. The container of Operation: Click Start, stop, restart, destroy operate the container server running in the page, which docker start | stop | restart | rm container name

12 .. container real-time log: Click the log, you can view real-time log of the container, which docker logs -f container name

Installation Tutorial

1. System Preparation

  • This system supports only Centos7 system
  • Configuration 2H4G
  • Fixed ip

1. The separation of a virtual machine as a runtime environment company server easyci, requiring as shown above in FIG.

Note: The virtual machine is best not to run other services because easyci will first test the deployment of the results of running the local container, and then sent to a remote server running container, pay attention to occupy the port.

2. easyici.zip by winscp or xftp like.

Here I put / root directory.

 3. Connect server through xshell or other tools.

 4. Enter / root directory, unzip easyci.zip

 If no decompression unzip command can be executed yum install -y unzip installation

Unpack again. Generate easyci folder after decompression.

 5. Go to the folder easyci

 6. edit install.sh, line 35 to modify the modified native localhost ip

  • we install

Press and hold the "ℹ️" enter edit, modify localhost native ip

 After editing, press the "Esc" to exit edit mode, press ":" Enter wq enter, save.

 The install script is easyci system deployment to install all the tools needed, can be adjusted as needed.

7. Run the install script, system installation

  • bash install.sh

System installation will last about 20 minutes, specifically to see the network speed.

The following diagram, our system the tools needed to complete the initial installation.

 

 8. Overload / etc / profile configuration file.

  • source /etc/profile

Test java, maven, node commands such as whether the normal installation.

  • java -version
  • mvn -v
  • node -v
  • asl -v

 ok, hold down the complete tool.

9. permanently closed selinux

  • vi /etc/selinux/config

The SELINUX = enforcing changed SELINUX = disabled
after setting need to restart to take effect.

10. Open the root user remote access mysql.

  • mysql -hlocalhost -uroot -p123456
  • grant all privileges on *.* to root@"%" identified by ".";
  • flush privileges;
  • exit

 11. Start System

 Easyci system into the home directory / home / easyici

./StartEasyCi.sh start execution system

  •  netstat -tunlp | grep -E "9875|81"

View front-end and back-end port 81 9875 port is open successfully.

Tutorial

1. Open a browser to access the system ip: 81

 The system starts first need to verify gitlab.

gitlaburl: Enter gitlab address, do not add http:

Username Password: We recommend the user name and password for an administrator root user name and password.

Note: Do not include password here @ / other special symbols, or free certification of git pull fails

Click here to enter the login background gitlab api calls to get the access-token, is used in the server pulls free confidential pull the code, select the project to build the deployment.

2. Add the remote server deployment

 Click Add to enter information, the public key system will cost raw server, the file is added to the authentication server to achieve free secret landing.

Containers docker will show a list of the server after the addition is complete, you can start, stop, restart, destruction, view real-time logging operation.

 Adding servers, displays the list server to add a list of containers and a container of the present machine.

如果有多个远程服务器,可以选择某个服务器,查看该服务器的容器列表,也可以开启自动刷新,实时刷新容器数据。

 “启动|停止|重启|销毁”等操作同步docker start|stop|restart|rm 容器名称。

“日志”可以查看该服务器的实时日志,即docker logs -f -tail 200 容器名称。查看该容器近200行日志,并实时刷新。

 3.项目构建

点击选择需要部署的gitlab醒目

 端口输入端口映射对。

由于是采用docker容器运行。需要设置映射端口

例如6000:5000

前面的6000为宿主机对外访问开放的端口,后面的5000为构建项目的端口,注意“:”为英文状态下

项目语言选择vue或者java。

收件人邮箱:如果有多个以“,”分割

部署方式:选择要部署的服务器。

注意:本系统是在本地先运行测试容器是否正常运行。运行正常则本地会删除容器释放端口,再发布到远程服务器运行。

所以注意本地端口占用。系统初始端口如下:

22、25、81、5000、3306、9875、68、323

即端口映射前面的端口不能为上述端口。

 如果本地或者远程端口被占用,会停止构建,弹窗提醒。

这里easyci本地运行的docker私服占用了5000端口,再发布5000端口的宿主映射会提示“端口已被占用”

 换其他端口,开始部署,显示部署日志

 容器部署成功会有邮件提醒。

 部署日志

Guess you like

Origin www.cnblogs.com/jxd283465/p/11714490.html