Should I have multiple build.xml files for one project (dev,staging,production)

十年热恋 提交于 2019-12-07 16:33:09

问题


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.

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.


回答1:


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:

So to give some details:

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.

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.




回答2:


You can make two tasks, e.g. "ftp_to_dev" and "ftp_to_staging", then just call the one you want.



来源:https://stackoverflow.com/questions/6986954/should-i-have-multiple-build-xml-files-for-one-project-dev-staging-production

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!