just ram

stuff I should remember

Jenkins.NET Setting up your first job

This post is part of a series:

  1. Jenkins.NET
  2. Jenkins.NET Plugins
  3. Setup Jenkins.NET
  4. Setting up your first job
  5. Your first build
  6. Breaking the build
  7. Diagnosing and fixing a broken build
  8. Monitoring your build
  9. Running your tests
  10. Code Analysis
  11. Security
  12. Active Directory Security

In Jenkins the definition of a build process is called a Job. Jobs are created using the main menu on the Jenkins home page. We’ll create a basic Job that will checkout our source and build the solution.

From the main Jenkins menu, Click the ‘New Job’ link.

You now see the New Job configuration page.

  1. Set Job name to Demo.
  2. Select the ‘Build a free-style software project’ radio button.
  3. Click the ‘OK’ button.

Jenkins will now create the Job workspace on disk and redirect you to the job configuration page.

Next we’re going to checkout our solution from source control and build it. So we first need to give Jenkins details of our source control server.

Source Control

For the purpose of this demo we’ll use Subversion, mainly because this is the source control management software I use day to day. Subversion is a very popular open source choice for .NET.

Jenkins supports Subversion right out of the box but it also has support for all the major source control management systems. For example here are few which are popular for use with the .NET framework:

  • Team Foundation Server Plugin - This plugin integrates Microsoft Team Foundation Server source control to Jenkins.
  • Mercurial Plugin - This plugin integrates the Mercurial version control system with Jenkins.
  • Git Plugin - This plugin allows use of Git as a build SCM. Git 1.3.3 or newer is required.
  • Visual SourceSafe Plugin - This plugin integrates Jenkins with Microsoft Visual SourceSafe.

Visual SourceSafe, seriously? Maybe you’re being forced to use it at gunpoint? If not do yourself a favour and check out Subversion. VisualSVNServer is a very easy to install, administer and use on Windows best of all its free! There is also a great Subversion Plugin VisualSVN for Visual Studio that I highly recommend.

I have created a Subversion repository on GoogleCode that we’ll use to demo the build process from Jenkins. Lets setup our Job to grab the source code from this repository. This is done in the Source Code Management section of the configuration page.

  1. Select the Subversion radio button.
  2. Set the Repository URL to: https://jenkins-net-demo.googlecode.com/svn/trunk

Subversion Authentication

Unlike the demo repository used here, it’s more likely your source code repository requires authentication (if it doesn’t, you may want to think about securing it). If your repository does require authentication Jenkins will display and error message and ask for you to supply login credentials.

Click the “enter credential” link. You will now be shown the Subversion Authentication page.

Enter your authentication details and then click the “OK” button.

Subversion is now configured and we can move onto Build Triggers.

Build Triggers

We want to trigger a build every time our source code changes; we achieve this by creating a “Build Trigger” which polls our source code repository. When a change is detected a new build is triggered.

  1. Under the Build Triggers section, tick the Poll SCM checkbox.
  2. Enter “5 * * * *” in the Schedule text area, this translates to check for changes every 5 minutes.

As you can see from the help (which is available by clicking the icon) we can be extremely flexible in how often we check the source code repository for changes. Checking every 5 minutes is my default as I tend make lots of small commits and I want to know quickly if I’ve introduced a problem.

Finally we just need to tell Jenkins how to build the solution when changes are detected. This is done via the “Add build step” button under the Build section.

  1. Click the “Add build step” button and select “Build a Visual Studio project or solution using MSBuild”.

  2. This adds a “Build a Visual Studio project or solution using MSBuild.” area under the Build section.

  1. Set “MsBuild Version” to V3.5 (The version we setup previously)
  2. Set “MsBuild Build File” to the name of the demo solution: Jenkins-net-demo.sln
  3. Click the “Save” button and you’ll be redirected to the Demo project page

Congratulations your first Jenkins Job is setup.

In my next post we’ll build it!

Comments