Agile development-continuous integration

Source: Internet
Author: User
Tags continuous integration tools

Software integration is not a new problem or concept. When a person develops a product independently, for example, during graduation design, there is no software integration at all, and there is no need to consider continuous integration! It's up to three to five people, seven to eight shots. When we were developing our team, we had to think about this problem! In traditional waterfall development, module development is performed independently. When all modules are fully developed, integration between modules is performed. Many nightmares occur at this time: different interfaces and different modules have different understandings of requirements ......

It usually takes ten days and a half months to get it done!
Martin Fowler (Thoughtworks The company's "bearded man") annotation for continuous integration is as follows:
Continuous integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily-leading to multiple integrations per day.
Each integration is verified by an automatic build (including test) to detect integration errors as quickly as possible. deleteams find that this approach leads to significantly CED integration problems and allows a team to develop cohesive software more
Rapidly.
I think it can be understood in this simple way: developers can integrate code early and discover problems in code in a timely manner through various tools to ensure the stability and accuracy of code quality, let agile Declaration 2 working software Implemented!
Next we will follow Martin Fowler To introduce continuous integration:
1) maintain a single source Repository
Generally, projects are developed in the form of teams. All the files in a project are calculated by. If you need to manually track and synchronize these files, it is no doubt a fantasy. The source code management tool came into being. Open-source code management tools include CSV , Subversion I personally think Subversion It is easy to use.
Rational Produced by clearcase It is more powerful, but not very cheap. We can create a stream for the project on these source code management tools. And then you can Create your own child
Stream, After the code is modified, we will deliver the code. To the code library, the code management tool will synchronize code for us. In this way, you can develop based on the latest code.
2) Automate the build   
From getting the source code to becoming a runable system, it takes a complicated process. A simple process may be: Compile/ Package source code, copy the package to the server, and start or restart the server. . Even in such a simple process, You have to enable the IDE In order to make it easier to compile the source code, IDE is generally not used in the integrated server. . The "Laziness" feature of developers forces them to develop new tools to complete this annoying process. Java The community developed ant ,. Net Nant developed by the community And msbuild . With these tools, we can hand over the complex, repetitive, monotonous, and boring work to the tools through some configurations. Because ant The function is really powerful, so I will try again later to add ant .
3) make your build self-testing   
In the traditional development mode After a version is released, we often need to call everyone (because it is a sub-module development). It takes several hours to perform manual testing on the system. Depressing: even if a manual test is performed, it seems that there is no problem on the surface, which cannot ensure the correctness of the background logic. We do not have automake the build Then we can add some automated testing tasks to it. These automated tests are performed in build In the process, check the logic correctness of the Code, analyze the complexity of the Code, point out the potential danger of the Code, test the integrity and accuracy of the system functions, test the behavior of the system, and so on. Of course, it's not that we go to ant You can add several commands in the script to complete these functions. Instead, you need to write the corresponding test code while writing the function code.
Driven Development (TDD , Test-driven development ), First write test, then write implementation! In general, the test includes the background logic test ( Nunit ), Test the foreground script logic (JavaScript Jsunit ) To test whether the page function is correct (selenium is generally used ). ) To analyze the complexity of the Code (you can use ) To analyze potential risks of the Code (using findbugs ).
4) Everyone commits every day   
Integration is often used to communicate and tell other developers that they have made those code changes. The importance of timely communication in team development is unquestionable. Therefore, we need to submit our code changes as soon as possible. Before submitting the code, make sure that your code is correct and at least the system can run. Instead of modifying the code, you just need to get the code up. For the entire team, cost Will be bigger! So do I have to submit code every day? I think it is necessary to analyze specific issues!
5) Every commit shocould build the mainline on an integration Machine   
As mentioned above, code submission every day may cause a problem: You may not get the latest code before submitting the code. Even if you get the latest code, due to different development environments, you may not find any problems. So the Code went up, and another colleague went to get the latest code. Maybe the whole system could not run. Therefore, we also need an integrated machine that obtains the latest code after each code submission, and then runs the corresponding test according to the settings, check whether the Code submitted this time has any problems. In this way, you can find the problem and the corresponding owner before the next colleague obtains the new code. To reduce extra work. Cruisecontrol (By thoughworks Developed by the company and contributed to the open-source community) This tool can achieve this: it can listen to the code library for any code changes, if any, it can get the latest code, then run the test task. About cruisecontrol For more information, see the instructions on the official website.
6) Keep the build fast   
As we mentioned above, continuous integration aims to discover problems faster and early. Therefore, it may take several hours or even a day for one integration. One build It will take one day, or distributed), and the meaning of continuous integration will be lost. Therefore, the faster the integration action triggered by each code submission, the better, XP (EXtreme Programming) outlines each build In 10 Within minutes is the most ideal. But in fact, it is very difficult to do this in many cases, a UAT It usually takes several minutes, And the restart time is also indispensable. So I think this is fast enough for different projects.
7) test in a clone of the production environment   
The purpose of the test is to check the usage of the product. Therefore, it is best to build an integrated machine environment consistent with the environment of the final product, such as the same database, the same server, and the same operating system.
8) everyone can see what's happening   
Continuous integration is a kind of communication. We should allow all people to see continuous integration in real time and conveniently. A simple method is to install a jcctray ( Http://jcctray.sourceforge.net/
), Configure the response parameters. After you start it, you can see a circle icon in the lower right of the desktop. When the icon is green, it indicates that the last continuous integration was successful, when the icon is red, it indicates that the last integration failed, and when it is yellow, it indicates that continuous integration is in progress. The following icon shows the problem with the last integration:

There is also a kind of is to use a lamp to show, the meaning of red, green and yellow with the above, the specific can see the http://www.pragmaticautomation.com/cgi-bin/pragauto.cgi/Monitor/Devices/BubbleBubbleBuildsInTrouble.rdoc
9) Automate deployment  
When a new code is obtained and tested, the system automatically deploys the code. For example, it is automatically deployed to QA.Environment, many servers can be automatically deployed using antSo the specific server has to view the corresponding antTask.

According to Martin FowlerDescribes the whole process of continuous integration. I personally think continuous integration is not only in AgileIt is necessary. In the traditional development mode, continuous integration is also a lot of help for the entire development, especially to improve the Code stability and correctness.

Some Ideas about using continuous integration tools should be recorded later.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.