开发者

Can Nant be used to deploy to different servers?

Can Nant be 开发者_运维问答used to deploy an application to a different set of servers based on some type of property/parameter?

What I need NANT to do: An environment is made up of 1 or more servers. We have multiple environments (dev, qa, prod). The package contains multiple web-site projects.

When NANT is asked to build for DEV, it needs to build the projects and setup the web.config up correctly to work in the DEV environment (connection strings, etc). In addition each web-site project needs to be deployed to the correct server for that environment.

In addition, can NANT be used to build all my projects once and then deploy it multiple times (deploy to Dev, QA, Prod environments?) (ie, the build and deploy are done at different times and once a build has been created, the deploy could be run on that build package multiple times)


Look at my answer here for Configuration Management: Should I have multiple build.xml files for one project (dev,staging,production)

Basically you need environment configs for DEV, QA, PREPROD, PROD etc, specify the environment you want to deploy during deploy ( say from command line through -D:environment=DEV ) which will use the appropriate config and deploy.

Build once, deploy everywhere is the general approach you should follow. Build and deploy should be separate targets. Use a CI tool if needed ( like Jenkins, TeamCity) to build the application. Expose the build application ( zip, tar, war etc) as Artifacts. In the deploy target, download the necessary artifact and do the deploy.


I have a similar NAnt solution in place and this is what works well form me. In the same build file, I define different targets for compiling and setting up the different config files for each environment. My deployment target takes uses 3 parameters: copy source, copy destination, config file.

The files are copied from source to destination. Then the specified config file (Web.config.dev, Web.config.qa, Web.config.production) are copied to the destination and renamed to Web.config.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜