Is there any possibility to automate/semi-automate deployments of ASP.NET web applications using Jenkins. It can be under controlled or uncontrolled environments, for uncontrolled user needs to enter userid and password. I am looking out for ways to copy the files from target to destination and run sql scripts in web farm scenario.

Edit Currently we are using bat files to xcopy/configure app pool/sql cmd, etc to deploy the application. But for this to work, production support team needs to download the source code, build the project and run the bat files to deploy the application.

Now, we want to automate the deployment without user downloading the source code and end user just needs to visit a url and fill userid and password parameters and select svn tag and it should get deployed. But Jenkins is running under anonymous login, so the existing bat file will not work since it doesn't have permissions to run the script.

So, I would like to know if there exists any alternatives for this kind of situation. It will be good if user context is impersonated by using entered userid and password allowing existing batch file to run without further changes. If it is not possible, we would like to explore other ideas too but we don't have flexibility to choose a automated tool like puppet, etc, we should stick around with these batch files.

  • Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see How to Ask
    – gnat
    May 2, 2013 at 20:58
  • Update my question, please let me know if I need to provide any additional information.
    – Sunny
    May 2, 2013 at 21:35

2 Answers 2


I'll share what we've been using, and where we're planning on going, maybe it'll help give you a better idea.

  • We currently use Jenkins and Github together-- once something is merged into master, Github tells Jenkins and it kicks off a build.
  • We use a Nant script on Jenkins to build the project, run unit tests, and if everything looks good, it kicks off another Jenkins project. The Nant script also spits out a directory with fully compiled code/minimized CSS/JS, etc.
  • The secondary Jenkins project takes the output from the build, and sends it back up to Github, on a separate repository.
  • A .BAT file runs every 5 minutes on the staging web server, and it basically checks for updates to that repository. If an update is found, we download the latest build, backup our staging files, then deploy the newest build over to staging folder.
  • To go live, we have a .BAT file that handles backing up the live files, and copying the repository files over the live files. It's run manually. It doesn't handle SQL updates (we do those by hand).

Now, obviously this isn't totally ideal but it's working for us. We want to expand this in the future to:

  • Use Web Deploy to push the files from Jenkins straight to IIS, and do any other commands we need to run.
  • Use automatic migrations (a feature of Entity Framework) to handle all SQL updates, as part of the go live.
  • It is almost same what we are following. But, I wondered if Web Deploy could install windows services, etc. and all that needed for complex web applications. Currently, we are using ps tools and its working fine. For DB, we planning to use DeployDB tool.
    – Sunny
    May 9, 2013 at 0:58
  • How do you handle situations when IIS is locking files? How do you handle situations when someone is working with your app. Do you have multiple nodes or just break application for users working at the time of publish? Jun 15, 2013 at 1:08
  • 1
    @Peri - I forgot to mention in my original answer, but we are planning on having two production servers, and flipping between them when needed (using IIS or nginx). This will let us "warm" up the other live server when the deploy happens, and then switch over to it, so there shouldn't be noticable downtime. Jun 15, 2013 at 4:50

I am already using Jenkins for .Net apps and TFS.

  1. Add required configuration in your project and transformation & check-in the code.
  2. Get the latest from TFS (use TFS Plug-in)
  3. Build the Project (use MSBuild Plug-in). you can publish the code from Msbuild using command line arguments.
  4. Sync the code from publish location to destination using msdeploy.exe command (located at "C:\Program Files (x86)\IIS\Microsoft Web Deploy V2\msdeploy.exe")
  5. You can send emails and do the backup via Jenkins too.

You can also use MSTest.exe to execute unit test and show it at jenkin console or publish the test result also.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.