zoukankan      html  css  js  c++  java
  • 持续集成(Continuous Integration)

    持续集成简称CI,持续集成是频繁、持续的在多个团队成员的工作中进行集成,并且给与反馈。一个典型的持续集成周期包括以下几个步骤:
       1. 持续集成服务器不断从版本控制服务器上检查代码状态,看代码是否有更新。
       2. 如果发现代码有最新的提交,那么就从版本控制服务器下载最新的代码。
       3. 等代码完全更新以后,调用自动化编译脚本,进行代码编译。
       4. 运行所有的自动化测试。
       5. 进行代码分析。
       6. 产生可执行的软件,能够提供给测试人员进行测试。
       持续集成服务器,比如CruiseControl或者VSTS
       CruiseControl, Anthill, Bamboo, TeamCity, Continuum,hudson

    一个开源的持续继承环境:Jenkins

    下面就来介绍一下这个软件的安装,ubuntu 11.10环境为例

    一、安装Jenkins

    去官网下载,安装,很简单,他自己集成了一个java的环境和服务器,一个包搞定问题

    安装集成工具

    1、安装: ANT

    sudo apt-get install ant

    2、安装:pear

    sudo apt-get install php-pear

    3、安装:xdebug

    4、安装:phpunit

    sudo pear channel-discover pear.phpunit.de

    sudo pear install phpunit/PHPUnit

    5、安装:PHP_CodeSniffer

    sudo pear install PHP_CodeSniffer

    四、创建任务

    1. 下载模版配置:
      cd $JENKINS_HOME/jobsgit clone git://github.com/sebastianbergmann/php-jenkins-template.git php-templatechown -R jenkins:nogroup php-template/
    2. 重启Jenkins CLI:
      java -jar jenkins-cli.jar -s http://localhost:8080 reload-configuration
    3. 新建任务.
    4. 输入任务名称.
    5. 选择从已有任务拷贝
    6. 取消”Disable Build” 选项.
    7. 填写相关信息.
    8. 填写相关svn信息.
    9. 保存

    下面是项目build.xml文件(目前我们使用的配置)

    ==========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 server”>
    <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===============

    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=================

    进入jenkins的任务目录,一般是在:/var/lib/jenkins/jobs/

    进入指定的job/workspace目录

    替换目录中的的build.xml和phpunit.xml文件

    重启jenkins

    参考: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

  • 相关阅读:
    webgl-hdr
    color-balance-of-photoshop-using-opencv
    ssr
    hello girl
    牛人收集的162个JavaScript学习教程pdf资源
    What is the order of postprocessing effects?
    glslsandbox
    Geeks3D’s GLSL Shader Library
    face swap
    Leetcode 115.不同的子序列
  • 原文地址:https://www.cnblogs.com/DaBing0806/p/4909886.html
Copyright © 2011-2022 走看看