Home > Agile, Build Automation, C#, Selenium, Test Automation > Setup Jenkins on Windows and integrating it with NAnt

Setup Jenkins on Windows and integrating it with NAnt


Continuous integration (CI) implements continuous processes of applying quality control — small pieces of effort, applied frequently. Continuous integration aims to improve the quality of software, and to reduce the time taken to deliver it, by replacing the traditional practice of applying quality control after completing all development. I was interested in integrating the NAnt build tool with the Continuous Integration Tool and I choose Jenkins, which is an open source continuous integration tool written in Java.


  • Maintain a code repository: This practice advocates the use of a revision control system for the project’s source code. All artifacts required to build the project should be placed in the repository. In this practice and in the revision control community, the convention is that the system should be buildable from a fresh checkout and not require additional dependencies.
  • Automate the build: A single command should have the capability of building the system. Many build-tools, such as make, have existed for many years. Other more recent tools like Ant, Maven, MSBuild, OpenMake Meister or IBM Rational Build Forge are frequently used in continuous integration environments. Automation of the build should include automating the integration, which often includes deployment into a production-like environment.
  • Make the build self-testing: Once the code is built, all tests should run to confirm that it behaves as the developers expect it to behave.
  • Everyone commits to the baseline every day: By committing regularly, every committer can reduce the number of conflicting changes. Checking in a week’s worth of work runs the risk of conflicting with other features and can be very difficult to resolve. Early, small conflicts in an area of the system cause team members to communicate about the change they are making. Committing all changes at least once a day (once per feature built) is generally considered part of the definition of Continuous Integration. In addition performing a nightly build is generally recommended.
  • Every commit (to baseline) should be built: The system should build commits to the current working version in order to verify that they integrate correctly. A common practice is to use Automated Continuous Integration, although this may be done manually. For many, continuous integration is synonymous with using Automated Continuous Integration where a continuous integration server or daemon monitors the version control system for changes, then automatically runs the build process.
  • Keep the build fast: The build needs to complete rapidly, so that if there is a problem with integration, it is quickly identified.
  • Test in a clone of the production environment: Having a test environment can lead to failures in tested systems when they deploy in the production environment, because the production environment may differ from the test environment in a significant way. However, building a replica of a production environment is cost prohibitive. Instead, the pre-production environment should be built to be a scalable version of the actual production environment to both alleviate costs while maintaining technology stack composition and nuances.
  • Make it easy to get the latest deliverables: Making builds readily available to stakeholders and testers can reduce the amount of rework necessary when rebuilding a feature that doesn’t meet requirements. Additionally, early testing reduces the chances that defects survive until deployment. Finding errors earlier also, in some cases, reduces the amount of work necessary to resolve them.
  • Everyone can see the results of the latest build: It should be easy to find out whether the build breaks and, if so, who made the relevant change.
  • Automate deployment: Most CI systems allow the running of scripts after a build finishes. In most situations, it is possible to write a script to deploy the application to a live test server that everyone can look at. A further advance in this way of thinking is Continuous Deployment, which calls for the software to be deployed directly into production, often with additional automation to prevent defects or regressions.


  • Windows 7 as OS
  • Microsoft Visual Studio 2010 as IDE
  • NAnt as Build tool
  • NUnit as Unit Testing Tool
  • Selenium as a Test Automation Tool
  • Jenkins as Continuous Integration Tool
  • Java Installed (v1.7)
Java version Check:
  • Context-click ‘Computer‘, select ‘Properties‘ option.
  • Add the Java path in the ‘Path‘ System variables under ‘Advanced system settings ->Environment Variables‘.
  • Open the Command Prompt and type java -version and hit the ‘Enter’ key. Command Prompt will display following info:
 java version “1.7.0_05”
Java <TM> SE Runtime Environment <build 1.7.0_05-b05>
Java HotSpot<TM> Client VM <build 23.1-b03, mixed mode, sharing>
Jenkins Installation:
  • Download the Jenkins installer (jenkins.war) from the location: http://jenkins-ci.org/
  • Place the jenkins.war file in the location: C:\Development\Tools\Jenkins
  • Context-click ‘Computer‘, select ‘Properties‘ option. Then, Go to ‘Advanced system settings ->Environment Variables‘.
  • Add a new System variable by Variable name ‘JENKINS_HOME’ and set the Variable value to ‘C:\Development\Tools\Jenkins\.jenkins’
  • Open the Command Prompt and navigate to the location: C:\Development\Tools\Jenkins
  • Type java -jar jenkins.war and hit the ‘Enter‘ key. Jenkins is fully up and running. I have used the Environment Variable because when I run the command again, Jenkins will look for this Environment Variable and will automatically know to run.
  • All the Jenkins files will be extracted within the folder ‘.jenkins’ and will be saved in the location: ‘C:\Development\Tools\Jenkins\’ as shown below:
  • Launch a browser. Open the URL: http://localhost:8080/ and hit the ‘Enter‘ key.
  • Browser displays the Jenkins Home page as shown below:
Configuring NAnt with Jenkins:
  • Open the URL: http://localhost:8080/
  • Click on the ‘Manage Jenkins‘ link in the LHS of Jenkins Dashboard. It puts up the ‘Manage Jenkins‘ page as shown below:
  • Click on the ‘Manage Plugins‘ link. It puts up the ‘Plugin Manager‘ page.
  • Click on the ‘Available‘ tab, check the ‘NAnt Plugin‘ option under the ‘Build Tools‘ group and hit the ‘Download now and install after restart‘ button.
  • Restart the system and the NAnt plugin is installed.
  • Open the URL: http://localhost:8080/
  • Go to ‘Manage Jenkins’ -> ‘Manage Plugins’ -> ‘Installed‘ tab. NAnt plugin is listed in the ‘Installed‘ list as shown below:
  • Now, go to the Jenkins Dashboard screen and click on the ‘New Job‘ in the LHS links.
  • Add a job name (‘SampleSolution.Build‘ in my example), set the ‘Build a free-style software project checkbox and click on the ‘OK‘ button.
  • Under the ‘Build‘ section, click on the ‘Add build step‘ dropdown menu and select ‘Execute NAnt build‘.
  • I will be referencing my previous post, where I have integrated the NAnt Build with my Selenium Automation script. Add the location of NAnt: C:\Development\Work\SampleSolution\src\SampleSolution.Build\Nant.build in the ‘NAnt Build File’ field.
  • Click on the ‘Apply‘ button and then on the ‘Save’ button.
  • Go to the Jenkins Dashboard screen and you can see a new job added to the task list as shown below:
Running the Build task:
  • Hover the mouse on the new build task (i.e., SampleSolution.Build‘ in my case) and click on the ‘Build Now‘ option.
  • Build is executed, tests are executed in GUI mode and the build execution result will be displayed on the Jenkins Dashboard.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: