我是否应该为一个项目(开发、暂存、生产)设置多个 build.xml 文件 [英] Should I have multiple build.xml files for one project (dev,staging,production)

查看:31
本文介绍了我是否应该为一个项目(开发、暂存、生产)设置多个 build.xml 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力让我的头脑围绕 ANT、CI、SVN 和部署.我有一个开发服务器、一个临时/质量保证服务器、一个生产服务器和构建服务器.

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 构建服务器 (bamboo) 将运行构建和 (FTP??) 然后到开发服务器.在某个时候,我们将决定将构建部署到登台服务器.我将如何更新作为 ANT 任务一部分的 FTP 信息?当我们部署到生产服务器时,同样的问题也适用.

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、环境其他部分的值等..在该环境中配置和运行您的应用所需的任何内容.

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.

假设您在 ant 中有一个部署"目标.让它从命令行读取一些属性环境"(-Denvironment=stage)

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

使用此属性读取配置文件和值并使用这些值进行部署.使用 convention over configuration 基于方法,其中有一些合理的默认值,只有当该值与特定环境的默认值不同时,配置文件才可能覆盖这些默认值.

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.

将有一个目标,environment"属性值指定要使用的环境配置.

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

这篇关于我是否应该为一个项目(开发、暂存、生产)设置多个 build.xml 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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