为PHP项目设置部署/构建/配置项周期 [英] Setting up a deployment / build / CI cycle for PHP projects

查看:241
本文介绍了为PHP项目设置部署/构建/配置项周期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是我的大部分时间的孤立开发人员,从事一些大型,主要是基于PHP的项目。我想专业化和自动化如何处理代码库的更改,并创建一个持续集成过程,使转换在一个团队中工作,而不必进行根本的更改。



我现在做的是,我为每个项目都有一个本地测试环境;我使用SVN为每个项目;更改在本地进行测试,然后通常通过FTP传输到在线版本。 API文档是从源代码手动生成的;单元测试是我慢慢进入的单元测试,它不是我日常生活的一部分。



我想象的构建循环会做以下事情: p>


  • 在本地测试后,变更集会被检入SVN。


  • 我开始构建过程。


  • API文件会自动生成 - 如果我没有设置它


  • 新版本通过FTP部署到远程位置(包括一些目录重命名, chmodding,导入数据库等等。)这是我已经非常喜欢 phing 的东西,但我


  • 运行驻留在预定义位置的单元测试。使用电子邮件,RSS或(最好)HTML输出,我可以抓取并放入网页,告知他们失败或成功。


  • 可选地)在预定义位置中的终端用户changelog文本文件被更新为具有提交消息的预定义部分(现在可以同时过滤foo和bar )。此消息不一定与SVN提交消息相同,后者可能包含更多内部信息。


  • 像代码度量,代码样式检查等


  • ul>

    我在寻找





    • 特别是良好的分步骤


    • 提供尽可能多的自动化功能的解决方案




    以及




    • 产品推荐。到目前为止,我所知道的是 phing / ant建筑, phpUnderControl Hudson 报告部分。我很喜欢他们,尽管我看到,但我当然没有与他们详细的经验。



    我是淹没了与工作,所以我有一个强烈的倾向于简单的解决方案。另一方面,如果一个功能缺失,我会哭泣它太有限。 :)点击解决方案也是受欢迎的。我也是可以与PHP项目一起使用的商业产品建议。



    我的设置



    我在Windows本地工作(7,准确),大多数客户端项目运行在LAMP堆栈,通常在共享主机(=没有远程SSH)。
    我正在寻找可以在我自己的环境中运行的解决方案。我准备好为此设置一个Linux虚拟机,没有问题。托管的解决方案对我来说很有趣,只有当他们提供所有描述的方面,或者足够灵活,足以与过程的其他部分交互。


    赏金
    我接受的答案,我觉得会给我最多的里程。这里有很多优秀的输入,我希望我可以接受多个答案。感谢大家!



    解决方案

    我经历过 buildbot CruiseControl.net CruiseControl Hudson 。虽然我真的很喜欢CruiseControl *,它是太多的麻烦,真正复杂的依赖案例。 buildbot不容易设置,但它有一个很好的光环(我只是喜欢python,这一切)。但哈德森赢得了前三个,因为:


    1. 这很容易设置

    2. 自定义

    3. 它看起来不错,并且有很好的概述功能

    4. 它自己和所有安装的插件都有点击更新。这是一个非常好的功能,我感激越来越多

    注意:我只使用linux作为上述构建的基础服务器(CC.net在 mono 上运行),但他们应该根据文档运行跨-platform。



    设置hudson服务器



    先决条件:




    • Java(1.5将为您提供服务)

    • 读取subversion服务器的权限(我有一个单独的hudson用户帐户) / li>


    从这里开始:

      java -jar hudson.war 

    这将在控制台上运行一个小型服务器实例,您可以在 http:// localhost:8080 上浏览安装,如果您没有事先在该端口上运行的任何东西(您可以指定另一个通过将 - httpPort = ANOTHER_HTTP_PORT 选项传递到上述命令),并且一切都在安装过程中顺利进行。



    如果您转到可用的插件目录( http:// localhost:8080 / pluginManager / available ),您会发现支持上述任务的插件(默认情况下安装了subversion支持)。



    如果你有胃口,你应该安装一个java应用服务器,如 tomcat 码头安装说明适用于所有主要应用服务器



    更新 Kohsuke Kawaguchi 已为hudson构建了 Windows服务安装程序



    < h1>在hudson中设置项目

    以下遍历中的链接假定​​运行的hudson实例位于 http:// localhost :8080


    1. 选择新作业( http:// localhost:8080 / view / b>
    2. 为作业命名并点击创建一个自由风格的软件项目 / code>

    3. 按确定将转到作业的配置页面。所有的选项有一个小问号,除了他们。

    4. 在源代码管理选项组下,您将使用Subversion。 Hudson接受网址访问以及本地模块访问

    5. 在选项组Build Triggers下,您将使用Poll SCM。这里使用的语法是cron的,所以每5分钟轮询subversion版本库将 * / 5 * * * *

    6. 构建项目的过程在选项组构建下指定。如果你已经有一个蚂蚁构建文件,所有的目标,你需要,你是运气。只需选择调用蚂蚁并写入目标的名称。选项组支持maven和shell命令以及开箱即用,但还有一个可用于phing的插件

    7. 在邮件构建操作中勾选其他构建操作,例如电子邮件通知或构建工件的归档。 >

    为了设置hudson没有插件的进程,您可以直接通过shell脚本从构建设置中调用它们,也可以撰写您自己的插件



    陷阱:




    • 如果你有它产生build artefacts,记得要定期清理hudson。 / li>
    • 如果您设置的项目超过20个,请考虑不要将其构建状态显示为hudson上的默认主页



      • 祝你好运!


        I am a lone developer most of my time, working on a number of big, mainly PHP-based projects. I want to professionalize and automate how changes to the code base are handled, and create a Continuous Integration process that makes the transition to work in a team possible without having to make fundamental changes.

        What I am doing right now is, I have a local test environment for every project; I use SVN for each project; changes are tested locally, and then transferred to the on-line version, usually via FTP. API documentation is generated manually from the source code; Unit tests are something I am getting into slowly, and it's not yet part of my daily routine.

        The "build cycle" I am envisioning would do the following:

        • A changeset gets checked into SVN after having been tested locally.

        • I start the build process. The SVN HEAD revision gets checked out, modified if necessary, and made ready for upload.

        • API Documentation gets generated automatically - if I haven't set it up in detail yet, using a default template, scanning the whole code base.

        • The new revision is deployed to the remote location via FTP (Including some directory renaming, chmodding, importing databases, and the likes.) This is something I already like phing for very much, but I'm open for alternatives of course.

        • Unit tests residing in a predefined location are run. I am informed about their failure or success using E-Mail, RSS or (preferably) HTML output that I can grab and put into a web page.

        • (optionally) a end-user "changelog" text file in a pre-defined location gets updated with a pre-defined part of the commit message ("It is now possible to filter for both "foo" and "bar" at the same time). This message is not necessarily identical with the SVN commit message, which probably contains much more internal information.

        • Stuff like code metrics, code style checking and so on are not my primary focus right now, but on the long run, they certainly will. Solutions that bring this out-of-the-box are very kindly looked upon.

        I am looking for

        • Feedback and experiences from people who are or were in a similar situation, and have successfully implemented a solution for this

        • Especially, good step-by-step tutorials and walkthroughs on how to set this up

        • Solutions that provide as much automation as possible, for example by creating a skeleton API, test cases and so on for each new project.

        and also

        • Product recommendations. What I know so far is phing/ant for building, and phpUnderControl or Hudson for the reporting part. I like them all as far as I can see, but I have of course no detailed experience with them.

        I am swamped with work, so I have a strong inclination towards simple solutions. On the other hand, if a feature is missing, I'll cry about it being too limited. :) Point-and-click solutions are welcome, too. I am also to commercial product recommendations that can work with PHP projects.

        My setup

        I am working on Windows locally (7, to be exact) and most client projects are run on a LAMP stack, often on shared hosting (= no remote SSH). I am looking for solutions that I can run in my own environment. I am ready to set up a Linux VM for this, no problem. Hosted solutions are interesting for me only if they provide all of the aspects described, or are flexible enough to interact with the other parts of the process.

        Bounty I am accepting the answer that I feel will give me the most mileage. There is a lot of excellent input here, I wish I could accept more than one answer. Thanks everyone!

        解决方案

        I've been through buildbot, CruiseControl.net, CruiseControl and Hudson. All though I really liked CruiseControl*, it was just too much of a hassle with really complex dependency cases. buildbot is not easy to set up, but it's got a nice aura (I just like python, that's all). But hudson won over the former three because:

        1. It's just easy to set up
        2. It's easy to customize
        3. It looks good and got nice overview functionality
        4. It got point-and-click updates, for itself and all installed plugins. This is a really nice feature, that I appreciate more and more

        Caveat: I only ever used linux as base for the above mentioned build servers (CC.net ran on mono), but they should all - according to the docs - run cross-platform.

        Setting up a hudson server

        Prerequisites:

        • Java (1.5 will serve you just fine)
        • Read access to the subversion server (I have a separate account for the hudson user)

        From here, it's just:

        java -jar hudson.war
        

        This will run a small server instance right off your console, and you should be able to browse the installation at your http://localhost:8080, if you don't have anything else running on that port in advance (you can specify another port by passing the --httpPort=ANOTHER_HTTP_PORT option to the above command) and everything went well in the 'installation' process.

        If you go to the available plugins directory (http://localhost:8080/pluginManager/available), you'll find plugins for supporting your above mentioned tasks (subversion support is installed per default).

        If that has whet you appetite, you should install a java application server, such as tomcat or jetty. Installation instructions are available for all major application servers

        Update: Kohsuke Kawaguchi has constructed a windows service installer for hudson

        Setting up a project in hudson

        The links in the following walk-through assumes a running instance of hudson located at http://localhost:8080

        1. Select new Job (http://localhost:8080/view/All/newJob) from the menu on the left
        2. Give the job a name and tick Build a free-style software project on the list
        3. Pressing 'ok' will take you to the configuration page of the job. All the options have a little question mark besides them. Pressing this will bring up a help text regarding the option.
        4. Under the option group 'Source Code Management' you would be using Subversion. Hudson accepts both url access as well as local module access
        5. Under the option group 'Build Triggers', you would use 'Poll SCM'. The syntax used here is that of cron, so polling the subversion repository every 5 minutes would be */5 * * * *
        6. The process of building the project is specified under the option group 'Build'. If you already have an ant build file with all the targets you need, you're in luck. Just choose 'Invoke ant' and write the name of the target. The option group supports maven and shell commands as well out of the box, but there is also a plugin available for phing.
        7. Tick off additional build actions in 'Post Build Actions', such as e-mail notifications or archiving of build artefacts.

        For setting up processes for which hudson have no plugins, you can either call them directly through a shell script from within the build setup, or you could write you own plugin

        Pitfalls:

        • If you have it produce build artefacts, remember to have hudson clean up after itself in regular intervals.
        • If you have more than 20 projects set up, consider not displaying their build status as the default main page on hudson

        Good luck!

        这篇关于为PHP项目设置部署/构建/配置项周期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆