While most of my work is Mac/Unix based some of my business work is built on VB.NET/ASP.NET inside a Windows development. While striving for more robust, predictable code I chose to implement a Continuous Integration (CI) system. I had already used CI in large scale game production environments with great success following the TDD model.
Setting up a Continuous Integration server was the 1st task and I chose Jenkins for the task in hand. This had to be setup on a Windows system so that it could invoke Visual Studio 2010 in order to build the required projects parts that were a mix of VB applications and ASP.NET web services. We also had a requirement to use Perforce as the SCM of choice.
I’m assuming you already have a working build of your product on a host machine with your VS2010 build already cleanly building via a solution file.
Here’s how I did it:
Install Java Runtime Edition (JRE)
Jenkins requires Java so you’re going to have to ensure you have that installed before you can go much further. Oracle maintain the JRE so go there now and pop back when you’ve got it installed.
Download and install Jenkins
Once again, there’s a nice handy page over at Jenkins HQ that includes all the info you need on how to get Jenkins installed. Don’t forget to come back for more settings.
Within our organisation we typically keep all of our development files in a common directory regardless of host machine that maps straight into the Perforce Depot at a consistent point. This ensures we can get developers up & running very quickly. In our case, it’s:
Firstly, we’ll relocate Jenkins into that directory so we can maintain it inside our Perforce Depot. So locate your downloaded & unpacked ‘jenkins.war’ and move it to:
To test our setup, we’re going to start a static server via the command prompt so we can see all the various messages it produces. This will help us spot errors and get to know how Jenkins works. Inside your Command Prompt issue:
java -jar C:\dev\Build\jenkins\jenkins.war
If this all looks good, then check the Jenkins web service is running by visiting the default web browser location http://localhost:8080/. Remember this is a localhost setting so it’ll only work if Jenkins is running properly. We’ll be running Jenkins as a Windows Service once we’re happy everything is running OK and we can trust it to work cleanly in the background and startup when the system starts.
Install MSBuild plugin for Jenkins
Here’s a link to the plugin you’re looking to setup locally: https://wiki.jenkins-ci.org/display/JENKINS/MSBuild+Plugin . You’ll notice there’s no download link on there as plugins are installed through the local Jenkins browser interface.
Inside the Jenkins browser you’ll be installing the MSBuild plugin via Jenkins>Manage Plugins>Available then you’ll find the MSBuild in the ‘Build Tools‘ section.
NOTE: This page should be populated with available plugins, however if you’ve just installed Jenkins and got to this point quickly then it’s likely that the list will be empty. If so then try 2 things. (a) wait for the repository to download but we warned there’s no indicators for this (b) restart Jenkins service to populate the list.
Configure location of MSBuild.exe
Go to your local Jenkins Configuration via http://localhost:8080/configure
Navigate down that page to MSBuild section
click ‘Add MSBuild‘
- Name: .NET 4.0
- Path : C:\Windows\Microsoft.NET\Framework\v4.0.30319
- Default Params: empty
You should now have the prerequisites to be able to make a build Job via Jenkins.
Add a new Build Job
— New Job http://localhost:8080/view/All/newJob
— Job Name: ProjectName
— Type: Build a free-style software project
Setup your Job to execute a MSBuild script:
Navigate down through Build -> Add Build Step -> Build a Visual Studio project
— MsBuild Version: .NET 4.0
— MsBuild Build File: C:\dev\Projects\ProjectName\Project.vbproj
That’s it for the basic build. You should now be able to get Jenkins to run your build job and have it build locally without errors. If it’s not working right, sort it out now before adding in SCM.
Continuous Integration via Perforce
Now you’ve got a working build (if not then read up and come back) it’s time to connect your local build to the Perforce depot so we can get your build system automatically syncing & building your project when anything changes in Perforce.
Install Perforce plugin
Install Perforce plugin for Jenkins in a similar way to how we installed the MSBuild plugin via Jenkins -> Manage Plugins -> Available
We’re now going to configure the default Perforce command for the whole of Jenkins.
Go to http://localhost:8080/configure and navigate down to Perforce section of the configuration click ‘Add Perforce‘
— Name: p4
— Path: C:\Program Files\Perforce\p4.exe
The system wide default Perforce command is now installed and ready for connection to a Job.
Add Perforce to Job
Next we’re going to join the command into the job so they execute when appropriate.
Go to the job configuration page for the Job you’re setting up and locate ‘Source Code Management‘ and select ‘Perforce‘
— P4PORT: your perforce server IP:1666
— username: your perforce username
— workspace: jenkins
Ensure the perforce workspace/view mappings are accurate inside the Job -> Perforce settings. A good way is to copy the view from a working p4 workspace inside the p4v application itself and replace the original workspace name with ‘jenkins’
Check Perforce Works
So now you’ve got a working installation of Jenkins, you’ve got your build working cleanly and it now Integrates your project from Perforce when you initiate a build. It’s all good but it’s not very Continuous. To make this work we’re going to get Jenkins to poll Perforce every 1 minute for changes and then automatically start the Job we already setup.
Find the setup portion inside Job -> Configure -> Build Triggers
— [x] Poll SCM (checked)
— Schedule :
# every minute * * * * *
Well, that’s it. You’ve now built yourself a Continuous Integration server to watch over you and make sure your builds are consistently building and you’ve not forgotten to add something to the repository, submit a complete working build or a myriad of other reasons.
You may want to install some desktop notifications for clients, setup some NUnit tests and really start building on the good foundations you’ve setup.
Incoming search terms for the article:
- jenkins visual studio
- how to install jenkins on windows
- jenkins setup on windows
- installing jenkins on windows
- setting up jenkins on windows
- install jenkins on windows
- jenkins system requirements windows
- install jenkins
- install msbuild
- jenkins system requirement
- jenkins prerequisites
- jenkins plugin instalation
- windows continuous integration
- jenkins system requirements
- jenkins visual studio tutorial
- jenkins localsystem
- jenkins java requirements windows
- Jenkins requirement
- Jenkins MSBuild Plugin
- jenkins manual remove build
- jenkins c#
- installation jenkins local
- how to configure jenkins with plugins
- builder jenkins
- does jenkins run on windows server 2012
- procedure of jenkins installation
- how to configure p4 jenkins
- How to install Jenkins in a Visual studio environment
- msbuild build file in jenkins
- Jenkins net requirements
- jenkins perforce
- jenkins visual studio integration
- jenkins windows installer
- jenkins-ci build job
- what are the prerequisites of setting up ci framework jenkins
- jenkins poll scm every day
- jenkins tutorial for windows
- add project to existing view jenkins
- jetkins continuous integration server system requirements
- jenkins requirements management
- Jenkins requirements
- jenkins msbuild example
- jenkins build visual studio c
- jenkins build scm filesystem where does it put the build
- jenkins build name plugin
- install jenkins job builder windows
- install jenkins ci
- how to install jenkins on windows machine
- how to copy a build configuration in jenkins
- download jenkins windows 2012
- download jenkins war for windows 7
- deploy jekins with perforce
- build visual solution from jenkins
- Jenkins Builder Plugin
- jenkins c# install
- jenkins minimum requirements
- jenkins master webservice
- jenkins how to poll if build ready
- jenkins hardware scale
- jenkins hardware requirements
- jenkins continuous integration server
- jenkins continuous integration job windows batch
- jenkins continuous integration
- jenkins connect to windows slave without jre
- jenkins ci setup
- jenkins c# start test
- Build using MSbuild in Jenkins