Search code examples
deploymentcontinuous-integrationnantrelease-management

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)


Solution

  • 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.