Continuous integration (continuous integration)

Source: Internet
Author: User
Tags checkstyle

Continuous integration is referred to as CI, continuous integration is frequent, continuous integration in the work of multiple team members, and give feedback. A typical continuous integration cycle consists of the following steps:
1. The Continuous Integration server constantly checks the code status from the version control server to see if the code is updated.
2. If you find that the code has the latest commit, download the latest code from the version control server.
3. After the code is completely updated, call the automated compilation script to compile the code.
4. Run all the automated tests.
5. Perform code analysis.
6. Produce executable software that can be provided to testers for testing.
Continuous integration server, such as CruiseControl or VSTS
CruiseControl, Anthill, Bamboo, TeamCity, Continuum,hudson

An open source, continuous inheritance environment: Jenkins

Here's a look at the installation of this software, Ubuntu 11.10 Environment for example

First, install Jenkins

To the official website to download, install, very simple, he himself integrated a Java environment and server, a package to solve the problem

Installing the Integration tools

1. Installation: ANT

sudo apt-get install ant

2. Installation: Pear

sudo apt-get install Php-pear

3. Installation: Xdebug

4. Installation: PHPUnit

sudo pear channel-discover pear.phpunit.de

sudo pear install Phpunit/phpunit

5. Installation: Php_codesniffer

sudo pear install Php_codesniffer

Iv. Creation of tasks

    1. Download Template configuration:
      CD $JENKINS _home/jobsgit clone Git://github.com/sebastianbergmann/php-jenkins-template.git php-templatechown-r Jenkins:nogroup php-template/
    2. Restart the Jenkins CLI:
      Java-jar jenkins-cli.jar-s http://localhost:8080 reload-configuration
    3. Creates a new task.
    4. Enter a task name.
    5. Select Copy from an existing task
    6. Cancels the "Disable Build" option.
    7. Fill in the relevant information.
    8. Fill in the relevant SVN information.
    9. Save

Here is the project Build.xml file (currently we use the configuration)

==========build.xml============

<?xml version= "2.0″encoding=" utf-8″?>
<project name= "Name-of-project" default= "Build" >
<target name= "Build"
depends= "PREPARE,LINT,PHPLOC,PHPCS-CI,PHPUNIT,PHPCB"/>

<target name= "Build-parallel"
depends= "PREPARE,LINT,TOOLS-PARALLEL,PHPUNIT,PHPCB"/>

<target name= "Tools-parallel"
Description= "Run tools in parallel" >
<parallel threadcount= "2″>
<antcall target= "Phpcs-ci"/>
<antcall target= "Phploc"/>
</parallel>
</target>

<target name= "clean" description= "Cleanup build Artifacts" >
<delete dir= "${basedir}/build/api"/>
<delete dir= "${basedir}/build/code-browser"/>
<delete dir= "${basedir}/build/coverage"/>
<delete dir= "${basedir}/build/logs"/>
</target>

<target name= "Prepare" depends= "clean"
description= "Prepare for Build" >
<mkdir dir= "${basedir}/build/api"/>
<mkdir dir= "${basedir}/build/code-browser"/>
<mkdir dir= "${basedir}/build/coverage"/>
<mkdir dir= "${basedir}/build/logs"/>
</target>

<target name= "Lint" >
<apply executable= "PHP" failonerror= "true" >
<arg value= "-L"/>

<fileset dir= "${basedir}" >
<include name= "**/*.php"/>
<modified/>
</fileset>

<fileset dir= "${basedir}/_test" >
<include name= "**/*.php"/>
<modified/>
</fileset>
</apply>
</target>

<target name= "Phploc" description= "Measure Project size using Phploc" >
<exec executable= "Phploc" >
<arg value= "–log-csv"/>
<arg value= "${basedir}/build/logs/phploc.csv"/>
<arg path= "${basedir}"/>
</exec>
</target>

<target name= "Phpcs-ci"
description= "Find coding standard violations using Php_codesniffer creating a log file for the continuous integration serv ER ">
<exec executable= "Phpcs" output= "/dev/null" >
<arg value= "–report=checkstyle"/>
<arg value= "–report-file=${basedir}/build/logs/checkstyle.xml"/>
<arg value= "–standard=mystandard"/>
<arg value= "–ignore=${basedir}/wind,${basedir}/_test,${basedir}/configs,${basedir}/www,${basedir}/data,${ Basedir}/library/utility/safehtml,${basedir}/library/utility/soap "/>
<arg path= "${basedir}"/>
</exec>
</target>

============end===============

Configuration of the PHPUnit

============phpunit.xml=============

<?xml version= "1.0″encoding=" utf-8″?>
<phpunit bootstrap= "_test/bootstrap.php" backupglobals= "false" backupstaticattributes= "false" strict= "true" Verbose= "true" >
<testsuites>
<testsuite name= "BankAccount" >
<directory suffix= "test.php" >_test/market</directory>
</testsuite>
</testsuites>
<logging>
<log type= "Coverage-clover" target= "Build/logs/clover.xml"/>
<log type= "coverage-html" target= "Build/coverage" title= "BankAccount"/>
<log type= "JUnit" target= "Build/logs/junit.xml" logincompleteskipped= "false"/>
</logging>
</phpunit>

============end=================

Enter Jenkins's task directory, typically in:/var/lib/jenkins/jobs/

Enter the specified Job/workspace directory

Replace the Build.xml and Phpunit.xml files in the directory

Restart Jenkins

Reference: Http://avnpc.com/pages/php-open-source-project-plus-travis-ci

Http://blog.windcache.com/archives/5

http://blog.csdn.net/wanghantong/article/details/40985653

Continuous integration (continuous integration)

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.