Jenkins — why continuous integration?

Time:2020-11-25

1、 Development model

1. Waterfall development model: process linear irreversible development model

Advantages:

1) easy to understand
2) after the completion of the current stage, we only need to pay attention to the subsequent stage
3) provide inspection nodes by stages for the project

inferiority:

1) the division of each stage is completely fixed, and a large number of documents are generated between stages, which increases the workload
2) due to the linear development model, users can only see the development results at the end of development, thus increasing the development risk.
3) the outstanding disadvantage of waterfall model is that it can’t adapt to the change of user’s demand.

 

2、 Agile development model

1. Concept

1) iterative development: the development process is divided into several small cycles, that is, one “big development” becomes multiple small development.
2) incremental development: deliver a usable product to the user after a development cycle, and divide iterations according to the new functions.

 

2. Advantages

1) early delivery: reduce development risk cost and reduce capital pressure.
2) risk reduction: timely understanding of market demand and reducing the risk of inapplicability of products.

 

3、 Continuous integration

The goal of continuous integration is to allow products to iterate quickly while maintaining high quality.

1. Characteristics of Jenkins

1) open source: Jenkins is a continuous integration tool based on Java language, which supports continuous integration and continuous deployment.
2) easy to install, deploy and configure: you can install by Yum or download war package, and install and deploy quickly through docker container, which is convenient for configuration management of web interface.
3) message notification and test report: integrate RSS / e-mail to publish the build results through RSS or e-mail notification when the construction is completed to generate JUnit / TestNG test report.
4) distributed construction: support Jenkins and let multiple computers build / test together
5) file identification: Jenkins can track which jars are generated and which version of jars are used in that build.
6) rich plug-in support: support extension plug-ins, you can develop tools suitable for your team, such as git, SVN, maven, docker, etc.

2. Components of continuous integration

1) an automatic build process: check out code, compile build, run test, result record, test statistics, etc. are all completed automatically without manual intervention.
2) a code repository: a version controller is required to ensure the maintainability of the code. As a material library for the construction process, SVN or Git is generally used
3) a continuous integration server: Jenkins is a continuous integration server with simple configuration and easy to use.

 

3. Benefits of continuous integration

1) reduce risk: since continuous integration continuously builds, compiles and tests, problems can be found early, so the cost of repair is less.
2) reduce repetitive work: automatically merge code, build, compile and test automatically, which saves a lot of repetitive work.
3) continuous inspection: continuous inspection of system health. Reduce release risk and problems
4) continuous deployment: continuously provide deployable unit packages,
5) continuous delivery: continuous delivery of usable version.

4. Continuous integration process

1) submit
The first step in the process is for developers to submit code to the code repository. All steps start with a commit of the local code.
2) test (first round)
The code warehouse configures hook for commit operation, and it will be tested automatically whenever the code is submitted or merged into the trunk.
3) build
Through the first round of testing, the code can be merged into the trunk, even if it is delivered.
After delivery, build first and then run a second round of testing. Build refers to converting source code into actual code,
For example, installation dependency, configuration of various resources (style sheets, JS scripts, images)
4) test (second round)
After the construction is completed, a second round of testing will be carried out. If the first round has covered all the test contents, the second round can be omitted. At this time, the construction steps should also be moved to the front of the first round of testing.
5) deployment
After the second round of testing, the current code is a deployable version, and all files of this version are packaged and sent to the production server. It’s deployment
6) rollback
If there is a problem with the current version, it is necessary to roll back to the build result of the previous version. The easiest way is to modify the symbolic link to point to the previous version of the directory.

5. Continuous integration process description

1) developers submit code every day and submit it to git warehouse
2) Jenkins uses git tools to pull code from git warehouse to the integration server, and cooperates with JDK, Maven and other software to complete code compilation, testing and inspection. Testing, packaging, etc,
In this process, if every step fails, the whole process will be re executed
3) Jenkins distributes the generated jar or war package to the test environment or production environment for deployment. The tester or user can access the application through the server.