Maintain a code repositoryIt is vital to maintain a revision control system for the project's source code . All artifacts that are required to build the project must be placed in the repository. In this practise and in the revision control community, the convention is that the system should be build able from a fresh checkout and not require additional dependencies. Extreme Programming advocate Martin Fowler also mentions that where branching is supported by tools, its use should be minimised. Instead, it is preferred for changes to be integrated rather than for multiple versions of the software to be maintained simultaneously. The mainline (or trunk) should be the place for the working version of the software.
Automate the buildHow can we automate the build ? With a single command we should have the capability of building the system. There are many build-tools, such as make, have existed for many years. Other more recent tools are frequently used in continuous integration environments. Automation of the build should include automating the integration, which often includes deployment into a production-like environment. In many cases, the build script not only compiles binaries, but also generates documentation, website pages, statistics and distribution media (such as Debian DEB, Red Hat RPM or Windows MSI files).
Make the build self-testingIt is of utmost importance that once the code is built, all tests should run to confirm that it behaves as the developers expect it to behave.
Necessitate that everyone in the team commits the code everyday. By committing regularly, every committer can reduce the number of conflicting changes. Checking in a week's worth of work runs the risk of conflicting with other features and can be very difficult to resolve. Early, small conflicts in an area of the system cause team members to communicate about the change they are making. Committing all changes at least once a day (once per feature built) is generally considered part of the definition of Continuous Integration. In addition performing a nightly build is generally recommended.These are lower bounds; the typical frequency is expected to be much higher.
Everyone commits to the baseline every day
Every commit (to baseline) should be builtThe system should build commits to the current working version to verify that they integrate correctly. A common practise is to use Automated Continuous Integration, although this may be done manually. For many, continuous integration is synonymous with using Automated Continuous Integration where a continuous integration server or daemon monitors the revision control system for changes, then automatically runs the build process.
Keep the build fastThe build needs to complete rapidly, so that if there is a problem with integration, it is quickly identified.
Test in a clone of the production environmentHaving a test environment can lead to failures in tested systems when they deploy in the production environment, because the production environment may differ from the test environment in a significant way. However, building a replica of a production environment is cost prohibitive. Instead, the test environment, or a separate pre-production environment ("staging") should be built to be a scalable version of the actual production environment to both alleviate costs while maintaining technology stack composition and nuances.
Make it easy to get the latest deliverableMaking builds readily available to stakeholders and testers can reduce the amount of rework necessary when rebuilding a feature that doesn't meet requirements. Additionally, early testing reduces the chances that defects survive until deployment. Finding errors earlier also, in some cases, reduces the amount of work necessary to resolve them.
All programmers should start the day by updating the project from the repository. That way, they will all stay up to date.
Everyone can see the results of the latest buildIt should be easy to find out whether the build breaks and, if so, who made the relevant change.
Automate deploymentMost CI systems allow the running of scripts after a build finishes. In most situations, it is possible to write a script to deploy the application to a live test server that everyone can look at. A further advance in this way of thinking is Continuous deployment, which calls for the software to be deployed directly into production, often with additional automation to prevent defects or regressions.
Common Pitfalls of Continuous IntegrationAs suggested above, the practise of continuous integration should not be confused with the tools that assist it (CI servers such as Cruise Control, Hudson, etc.). Continuous integration is first and foremost a matter of attitude rather than tools, and it relies on more than one kind of tool: tools for testing, tools for automating build processes, and tools for version control.
Continuous integration aims to lessen the pain of integration by increasing its frequency. Therefore, "any" effort related to producing intermediate releases, and which the team experiences as particularly burdensome, is a candidate for inclusion in the team's continuous integration process. This is the reasoning that leads teams to continuous deployment.