How much do you know about the CI (Continuous Integration) system?

In recent years, due to the increasing activity of open source projects and communities, continuous integration (CI) systems have been born, and more and more people have been hearing about collaborative development, agile development, iterative development, continuous integration and unit Test these pulling terms. However, most of them just hear what everyone is saying, and there are few companies in China that have a complete CI system process. On the contrary, some open source projects have a complete CI system, such as openstack. The automated process of code hosting -> code review -> code release is implemented. The "Gitlab+Gerrit+Jenkins" mode is adopted to deploy the docking environment on the server. You can go and play. Here I will briefly explain the issues involved. Silky ties.

As a programmer/society, I believe everyone is no stranger to "git". Git is [Linus Torvalds](https://baike.baidu.com/item/Linus Torvalds/9336769) to help manage the development of the Linux kernel. Open source version control software, Torvalds began to develop Git as a transitional solution to replace BitKe. Let's take a look at the git "family bucket":
various common git***

Git is a version control system, a command, and a tool.
Github is a warehouse that implements online code hosting based on git. It is open to the Internet, and the enterprise version requires money.
gitlab is similar to github. It is generally used to build git private servers in the enterprise, and you must build your own environment.
gitee is the code cloud, which is free for enterprises by oschina, so you don't need to build your own environment.
git-ce is the community edition, gitlab-ee is the enterprise edition, paid edition.

GitHub

GitHub is a hosting platform for open source and private software projects. Because it only supports git as the only repository format for hosting, it is named GitHub.
GitHub was officially launched on April 10, 2008. In addition to Git code repository hosting and basic web management interface, it also provides subscriptions, discussion groups, text rendering, online file editors, collaborative graphs (reports), and code snippet sharing ( Gist) and other functions. At present, its registered users have exceeded 3.5 million, and the number of hosted versions is also very large, including many well-known open source projects Spring, MyBatis, React, Vue, etc.
On June 4, 2018, Microsoft announced that it had acquired code hosting platform GitHub through a $7.5 billion stock transaction.

GitLab

GitLab is an open source project for a warehouse management system. It uses Git as a code management tool and builds a web service on this basis. The installation method is to refer to GitLab's Wiki page on GitHub. GitLab is a web-based Git warehouse management tool developed by GitLab Inc. using the MIT license, and has wiki and issue tracking functions. Use Git as a code management tool and build a web service on this basis. GitLab is developed by Ukrainian programmers Dmitriy Zaporozhets and Valery Sizov, and it is written in Ruby language. Later, some parts were rewritten in Go language. As of May 2018, the company has approximately 290 team members and more than 2,000 open source contributors. GitLab is used by organizations such as IBM, Sony, Jülich Research Center, NASA, Alibaba, Invincea, O'ReillyMedia, Leibniz-Rechenzentrum (LRZ), CERN, and SpaceX.
Jenkins
Jenkins is an open source continuous integration (CI) tool that provides a user-friendly interface. It originated from Hudson (Hudson is commercially available). It is mainly used to continuously and automatically build/test software projects and monitor the operation of external tasks (this comparison Abstract, write it temporarily, without explanation). Jenkins is written in Java and can be run in popular servlet containers such as Tomcat or independently. Usually used in conjunction with version management tools (SCM) and build tools. Commonly used version control tools include SVN and GIT, and build tools include Maven, Ant, and Gradle.
Gerrit
gerrit's working model is that all real merges are handled by gerrit. Our submission is only submitted to gerrit. Gerrit will notify the person in charge of the project to review the code. At the same time, it will also call some automated test construction tools to check whether the code meets the requirements. Only after all passes will they be merged into the main code. So you can think of gerrit as a door between the code and the committer.

Let's take a look at the process of this CI system.
1) Code hosting
on Gitlab. The project created on gitlab is set to Private. Ordinary users only have pull permission for this project and cannot directly push.
Git comes with code review function to
force Review: For projects created on Gitlab, the designated user has only Reporter permission, so that the user does not have permission to use the git push function and can only git review to the Gerrit system. Jenkins is monitoring project events on Gerrit. Trigger the build task to test the code. Jenkins marks the project with a Verified (information verification) success or failure mark via ssh gerrit, and successfully informs other personnel to Review (code review).
Gitlab protects the Master branch: Projects created on Gitlab can protect the Master branch. Ordinary users can create branches and submit code to their own branches. They do not have permission to directly submit to the Master branch. The user finally submits an application to merge his own branch. To Master, after the administrator receives the Merge request, after Review, he chooses whether to merge.
You can deploy gitlab and gerrit on two machines, so that gitlab can host gerrit code or serve as a backup of gerrit. Because gitlab and gerrit are synchronized, the code on gerrit will be synchronized to gitlab. In this way, even if the gerrit deployment machine fails, the code in it will not be lost, and you can go to gitlab to get it.
2) Gerrit audit code
Gerrit is a code review system widely adopted by Android open source projects. Ordinary users clone the project in gitlab to the local. After modifying the code, although they cannot directly push to the code center, they can submit it to gerrit for review through git review. After the gerrit relevant reviewer sees the review information, he judges whether it is passed or not, and submits it through commit. Then, the gerrit code will synchronize with gitlab.
The essence of Gerrit is that it does not allow direct synchronization of local changes to remote warehouses. The client must first push to the refs/for/* branch of the remote warehouse and wait for review. You can also compare the content status before and after code review submission on gerrit.
3) Jenkins code release.
After the user git review, the code passes the Jenkins automatic test (verified) and manual review, the code is only merged into the Gerrit project, and not merged into the Gitlab project, so it needs to be changed when the Gerrit project warehouse is changed Time is automatically synchronized to the Gitlab project warehouse. Gerrit comes with a Replication function.

Guess you like

Origin blog.csdn.net/yusujifeng/article/details/107871456