Saturday, November 9, 2013

Continuous Integration Presentation - Part 2

Continuing from Part 1, here is a step by step explaining how to setup Jenkins with MSBuild and Mercurial complete with links!

  • You are running Windows
  • You already have some flavour of Visual Studio installed
  • You already have NUnit Installed (if not click here)
  • You already have TortoiseHg installed (if not click here)

Step 1 - Install Jenkins
  • Download and Install Tomcat - Link
  • Download Jenkins Zip - Link
Copy the Jenkins WAR into the 'webapps folder of your Tomcat install.  It should be somewhere like this: 'C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps'.  Make sure the Tomcat server is running and then navigate to http://localhost:8080/jenkins/.

Step 2 - Install Plugins
You'll now want to click on 'Manage Jenkins' on the left hand menu, then 'Manage Plugins' from the middle.
On the 'Available' tab you'll want to click the following:
  • Green Balls
  • Jenkins Mercurial Plugin
  • Jenkins MSBuild Plugin
  • Jenkins NUnit Plugin
Then down the bottom of the page click 'Install without Restart'.

Step 3 - Configuring Plugins
Go back to 'Manage Jenkins' and click on 'Configure System' in the middle.  The setup for the Mercurial and MSBuild plugins is pretty much the same, just providing a name and path information.  For Mercurial you need to specify the directory that houses 'hg.exe' in the 'Installation directory' parameter.  For MSBuild you need to specify the full path to 'msbuild.exe' in the 'Path to MSBuild' parameter.

Step 4 - Creating and populating a Mercurial Repository
Create a folder somewhere on your file system.  Right click on the folder, go to 'TortoiseHg' then select 'Create Repository here'.  Click Ok in the next dialog (the defaults are fine), and congratulations you have a repository!  Now create a Visual Studio Solution in this directory with some code in it to compile and some NUnit tests to run.  Now we need to first Add the important files into the Repository and then Commit them.  First of all, right click on the folder you first created, goto 'TortoiseHg' and select 'Add Files...'.  In the next dialog box select everything except bin and obj, you don't need the generated binaries in source control.  Now right click on the original folder again, goto 'TortoiseHg' and select 'Commit'.  Put a message in the next dialog and click 'Commit' in the bottom right hand corner.

Step 5 - Creating your first Build (or Job)
From the Jenkins dashboard click 'New Job'.  Give it a 'Name', select 'Build a free-style software project', and then click 'OK'.  Then setup similar to the pictures below.
Now click 'Build Now' to test and hopefully it will go Green!

If your build breaks the main source of information will be the 'Console Output' from the build, and contrasting the paths in your configuration with those in the 'Workspace'.  The Workspace is the place that Jenkins downloads the repository files to and such all paths in the configuration are relative to that.

I hope this has been helpful, Good Luck!!


  1. Useful advice, but I had problems, I could not repeat it. I recently found a nice template for presentation Tell me, will I be able to use this software? I'll wait for an answer. Thank you in advance.

  2. G'Day Thomas,

    What problems are you having? I might be able to assist.