During software development, development members often need to integrate their work into the project, usually at least once per day. Software integration may not be a problem if the project is small and the external dependencies are small. However, many software projects, especially Internet projects, are confronted with a series of problems, such as unclear demand, complicated system structure, and confusion of task allocation, which brings a lot of trouble to continuous integration. It also poses unnecessary risks to the entire project. Therefore, an effective continuous integration system is becoming more and more important.
Push platform is an extremely complex distributed system, the whole system contains the RPC call, cache, cluster synchronization and other complex scenarios. The team has only 20 people who have maintained nearly hundred modules of development and testing, if there is no effective mechanism, it is difficult to imagine how to accomplish these tasks. Continuous integration plays a very important role in the use of tools such as Git, Docker, Jenkins, and Nexus to build up your own continuous integration environment and to develop your own best practices step-by-step. This article will share with you a push on how to use these technologies to improve the productivity of your team.
components of a continuous integration Systemusing Git as a version control library
Git has a very significant advantage over the same project version system, which is the ease of merging (merge) of the version Branch (branch).
using Docker to build a test environment
As a new type of virtualization, there are many advantages relative to traditional virtualization methods. For example, the launch of a Docker virtual container can be implemented in seconds, and the utilization of system resources is high. In addition, Docker management, migration and expansion are also easier and more effective.
using Jenkins as a continuous integration Server
Jenkins provides developers with a very effective continuous set management. Its powerful plug-in system and clear building logic make it easy to create a build process.
The role of Docker in continuous integration systems
Testing is an important part of a software project, and generally requires a development team to build a separate test system. But as a part of continuous integration, this test system is different from the general test system. The main reason is that the continuous integration test system is mainly used for regression testing, and it needs to support a rapid and large number of code upgrades. Docker-based features, as well as the need for continuous integration, push Docker to build a complete suite of test systems for continuous integration.
Image preparation:Docker runs based on image files, and the image files required for each project are different. It is therefore necessary to independently analyze the needs of each project and future expansion needs, creating different versions of the image files. At present, there are 4 major categories of images, such as front-end, back-end, tools and other items. Taking the front end as an example, a push takes the development pattern of a front-end separation, so this image is primarily used to support Web front-end service runs.
Service Pack Preparation: in order to run the required services in Docker, you need to install the appropriate service pack in the Docker instance. There are generally two ways to install the corresponding service pack in the image file, and the other to dynamically map to the Docker instance as a Docker volume. Both are good and bad, the first way to make each Docker container start very quickly, and the second way is more flexible. This needs to be based on different needs to choose the right way.
The role of Docker in the entire continuous integration system. Jenkins manages the code and Docker as a master server.
a push-to-continuous integration process
The following is an example of the user module, which illustrates the process of continuous integration, as shown in:
As you can see, the GIT branch of the system includes dev,master two branches:
- Dev: Development Branch, developer maintenance, developers submit the latest code to this branch, Jekins monitor this branch, any code changes will trigger the automated test
- Master: The release branch, the version on this branch is the version of the automated test pass, and automated packaging monitoring this branch
Each rectangle in the diagram represents a Jenkins Job. Each job is described below:
- User: Monitors the dev branch of the user code base and automatically triggers the build task each time a new code is submitted. Compile the code, and generate a code style, test coverage, and other reports on the quality of the codes. The User-docker task will be triggered when successful.
- User-docker: Package The user project and restart the user's Docker instance for easy access to the new user package. The TestCase task will be triggered after success
- TestCase: Acceptance testing to detect whether changes meet the acceptance criteria defined by the business requirements. The Marge task will be triggered after success
- Merge: Merge user's dev branch to master branch
- USER-PKG: Monitors the master branch of the user code base and, when there is a code change, performs a
mvn package packaging operation
Following the steps above, the entire process from code submission to packaging is automated.
Summary
More and more companies are starting to focus on continuous integration systems, but is there a lack of customized systems that can really meet complex needs? As the links between the modules become more complex, the frequency of integration becomes larger, the running environment is constantly escalating, and so on, the lack of a customized continuous integration system can be expected, and a solution is found on Docker. There are still many challenges, but as technology is upgraded and perfected, it will end up doing better.
Decrypt a push continuous integration