如果我有多个的build.xml文件一个项目(开发,运行,生产) [英] Should I have multiple build.xml files for one project (dev,staging,production)

查看:492
本文介绍了如果我有多个的build.xml文件一个项目(开发,运行,生产)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作让我的头上缠着ANT,CI,SVN和部署。我有一个开发服务器,中间/ QA服务器和生产服务器和构建服务器。

I'm working to get my head wrapped around ANT, CI, SVN and deploying. I have a dev server, a staging/qa server and a production server and the build server.

在理论上,CI构建服务器(竹)将运行构建和(FTP ??)然后到开发服务器。在某些时候,我们就决定部署构建到临时服务器。我将如何更新FTP信息是ANT任务的一部分?当我们部署到生产服务器同样的问题适用。

In theory, the CI Build server (bamboo) will run builds and (FTP??) then to the dev server. At some point, we'll decide to deploy a build to the staging server. How would I update the FTP information that is part of the ANT task? Same question applies when we deploy to the production server.

推荐答案

我认为你正在寻找配置管理?你的脚本本身应该做同样的事情,不论它们运行的​​ - 开发,分期或生产。但你可以有配置文件为每个环境,这将有具体到各自的环境配置值。该脚本会从这些配置文件读取的值并适当配置您的应用程序。

I think you are looking for configuration management? Your scripts themselves should do the same thing irrespective of where they are running - dev, staging or production. But you can have config files for each of your environments which will have configuration values specific to the respective environment. The scripts will read the values from these config files and configure your application appropriately.

和回答您的倍数直接的问题建立文件,没有,有单目标单生成文件的部署(多目标不是必需的,但可以根据情况使用),具体如下:

And to answer your direct question of multiple build files, no, have single build file with single target for deploy ( multiple targets are not necessary, but can be used depending on situation ), details below:

于是给一些细节:

有配置文件像dev.config,stage.config,prod.config(或的.properties 文件)等配置将有机IPS,值等部位环境,etc..anything需要为您的应用程序进行配置,并运行在该环境中。

Have config files like dev.config, stage.config, prod.config ( or .properties file) etc. The config will have machine ips, values for other parts of the environment, etc..anything needed for your app to be configured and run in that environment.

假设你有一个蚂蚁部署的目标。让它读取命令行某些属性的环境(-Denvironment =阶段)

Say you have a "deploy" target in ant. Let it read some property "environment" from the command line ( -Denvironment=stage)

使用这个属性读取配置文件和值,并使用这些值来部署。使用约定优于配置为基础的方法,其中也有一些理智的默认其值是否从默认的那个特定的环境不同的配置文件可能只覆盖。

Use this property to read the config file and the values and use these values to deploy. Use convention over configuration based approach, whereby there are some sane defaults which the config files may override only if the value is different from the default for that particular environment.

将有一个目标,以环境的属性值,指定环境的配置使用。

There will be a single target, with "environment" property value specifying the environment config to use.

这篇关于如果我有多个的build.xml文件一个项目(开发,运行,生产)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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