Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / productivity / biztalk

Continuous Integration using Jenkins

4.93/5 (6 votes)
15 Dec 2015CPOL21 min read 34.7K  
Pre-requisites to install Jenkins, Installation steps of Jenkins, Using Jenkins to build BizTalk/SharePoint projects, Validate using BizTalk Cop rules, Building from TFS, Maintain build order while building multiple projects, Send email for build failure

Overview of Jenkins

Jenkins, originally called Hudson, is an open source Continuous Integration tool written in Java. Jenkins is used by teams of all sizes, for projects in a wide variety of languages and technologies, including .NET, Ruby, Groovy, Grails, PHP and more, as well as Java.

Jenkins is easy to use and the user interface is simple and intuitive.  We will see how to get started with Jenkins in the next section. Jenkins is also flexible and extensible as many open source plug-ins are available for Jenkins. 

These plugins cover everything from version control systems, build tools, code quality metrics, build notifies, integration with external systems, UI customization, games, and much more. And installing them is quick and easy.

We used Jenkins for continuous integration for BizTalk 2009 and SharePoint 2013 Projects. It is also used to invoke code review tool to analyze the code and schedule the build options.

Pre-requisites for using Jenkins for BizTalk projects

Software Requirements

This section lists the software required for BizTalk build machine with Jenkins.

Microsoft Windows -  Can be either Windows Server 2008, Windows Server 2003, Windows® XP with Service Pack 3 (SP3), Windows Vista® with Service Pack 1 (SP1). Itanium (IA64) editions of Windows Server 2003 are not supported by the BizTalk Server runtime, however, BizTalk databases can be hosted on SQL Server running on IA64 hardware.

Internet Information Services (IIS)  Versions 6.0 and 7.0 are supported. Provides a scalable Web application infrastructure.

Required for: EDI, BAM, WSS Adapter, and UDDI.

Windows SharePoint Services -  A collection of services for Windows Server which you can use for sharing and collaborating. Supported versions: WSS 2.0 with Service Pack 3 (SP3), WSS 3.0 with Service Pack 1 (SP1), and Microsoft Office SharePoint Server 2007 (MOSS).

Required for: WSS Adapter.

Microsoft Office Excel 2007 -  Business Activity Monitoring (BAM) uses an Excel workbook to display a real-time view of business processes.

Required for: BAM.

Microsoft .NET Framework 3.5 with Service Pack 1 (SP1)  - The Microsoft .NET Framework 3.5 SP1 (formerly WinFX), is the new managed code programming model for Windows. It combines .NET Framework 2.0 with four new technologies: Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), Windows Workflow Foundation (WF), and Windows CardSpace (WCS, formerly “InfoCard”).

Required for: All BizTalk Server managed components.

Microsoft Visual Studio 2008 - Provides a development environment for building applications that target any device and integrate with any platform. Professional Edition is recommended, but Standard and Team System are also supported.

Required for: BizTalk Server Developer Tools and SDK component.

SQL Server 2005 SP2 or 2008 - A relational database server for processing high volumes of data. For optimal performance, we recommend SQL Server 2008 Enterprise Edition. In order to fully use the BizTalk Server 2009 SDK, or deploy BizTalk Server applications from a Visual Studio development environment, you must also install the SQL Server Development Tools.

Required for: BizTalk Server Runtime, EDI, and BAM.

SQL Server 2005 Notification Services  -  Enables the use of BAM Alerts. Note that this SQL Server 2005 feature is not included in SQL Server 2008, and must be downloaded separately.

Required for: BAM Alerts.

SQLXML 4.0 with Service Pack 1 - Enables XML support for your SQL Server database and allows developers to bridge the gap between XML and relational data. You can create an XML view of your existing relational data and work with it as if it were an XML file.

Required for: BizTalk Server Runtime, Administrative Tools, and BAM.

BizTalk Server 2009 - Used for building BizTalk based projects in the build server

FxCop and BizTalk latest version - Used for automated code review of BizTalk projects.  We need to install the same version of FxCop and BizTalk cop to work properly. 

Microsoft Team Foundation Server - Used for source code repository, which will be used as a plug-in with jenkins for automated builds

Java Latest version -  It is a pre-requisite for Jenkins as Jenkis is a Java based product. 

Required for: Jenkins

Jenkins Latest version -  It is the Continuous Integration software that is used to build the BizTalk projects

Pre-requisites for using Jenkins for SharePoint projects

Steps to prepare the Build System (When both VS 2013 and SharePoint 2013 are not installed) – Refer https://msdn.microsoft.com/en-us/library/ff622991.aspx which explains using TFS Team Build as CI Tool, but we need to use Jenkins instead

  • Install Java and Jenkins
    If your build system already has Jenkins installed on it, you can skip this step. Otherwise, install and configure Jenkins on your build system. Detailed steps for installing Jenkins are given later in this article.
  • Install Windows SDK
    The Windows SDK must be installed on your build system because it includes the GACUtil tool. GACUtil is used to install the SharePoint Tool assemblies on the build system. You can download the Windows SDK from this location: http://msdn.microsoft.com/en-us/windows/bb980924.aspx. After you download the Windows SDK, install it. (Note that the PowerShell script referenced at the end of this article eliminates the need for this step.)
  • Install Build Support for Apps for Office and Apps for SharePoint
    To build apps for Office and apps for SharePoint projects, several components must be installed on your system.
  • Install SharePoint Farm and Sandboxed Solution Build Support

    Since SharePoint farm and sandboxed solution projects reference SharePoint Server assemblies, those SharePoint assemblies must be present on the build system.
    One way to do this is to install the full version of SharePoint Server 2013 on your build system. An advantage of having SharePoint installed is that you can use it to deploy and test your SharePoint application immediately after generating the WSP file. Note, however, that SharePoint Server 2013 can degrade your system performance, and it has increased system requirements (such as requiring a 64-bit CPU).
    As an alternative, you can download the required SharePoint assemblies onto your build system. For either method, you will need the proper license of SharePoint on the build system. Copy the following assemblies from the development system to the build system and put them in a Reference Assembly folder:
  • Microsoft.SharePoint.dll
  • Microsoft.SharePoint.Security.dll
  • Microsoft.SharePoint.WorkflowActions.dll
  • Microsoft.Office.Server.dll
  • Microsoft.Office.Server.UserProfiles.dll
  • Microsoft.SharePoint.Client.dll
  • Microsoft.SharePoint.Client.Runtime.dll
  • Microsoft.SharePoint.Client.ServerRuntime.dll
  • Microsoft.SharePoint.Linq.dll
  • Microsoft.SharePoint.Portal.dll
  • Microsoft.SharePoint.Publishing.dll
  • Microsoft.SharePoint.Taxonomy.dll
  • Microsoft.Office.SharePoint.Tools.dll
  • Microsoft.SharePoint.WorkflowActions.dll
  • Microsoft.Web.CommandUI.dll

        These files are located in the following folder on the development system:
       C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI

        It is recommended that you copy the SharePoint Server assemblies to the folder:
                .. \Program Files\Reference Assemblies\SharePoint\

        And then add one of the following registry entries:

  • For 64-bit systems:
    HKEY_LOCAL_SYSTEM\SOFTWARE\Microsoft\Wow6432Node\.NETFramework\v4.0.30319\AssemblyFoldersEx\SharePoint15]@="<AssemblyFolderLocation>"
  • For 32-bit systems:
    HKEY_LOCAL_SYSTEM\SOFTWARE\Microsoft\.NETFramework\ v4.0.30319\AssemblyFoldersEx\SharePoint15]@="<AssemblyFolderLocation>"

        If your SharePoint Projects refer to other SharePoint Server assemblies, copy them to the build system as well.

  • Install Office Developer Tools Assemblies to the GAC
    The following assemblies must be copied to the GAC of the build system:
  • Microsoft.VisualStudio.SharePoint.Designers.Models.dll
  • Microsoft.VisualStudio.SharePoint.Designers.Models.Features.dll
  • Microsoft.VisualStudio.SharePoint.Designers.Models.Packages.dll
  • Microsoft.VisualStudio.SharePoint.dll

These files are located in the following folder on the development system:
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\

If you also need localized versions of the files, you should also copy and install the corresponding resource DLLs to the GAC of the build system:

  • Microsoft.VisualStudio.SharePoint.Designers.Models.Features.resources.dll
  • Microsoft.VisualStudio.SharePoint.Designers.Models.Packages.resources.dll
  • Microsoft.VisualStudio.SharePoint.Designers.Models.resources.dll
  • Microsoft.VisualStudio.SharePoint.resources.dll
  • Install Required MSBuild Dependencies
    Copy and install the following custom targets and tasks folders to the corresponding folders on the build machine:
    • .. \Program Files\MSBuild\Microsoft\VisualStudio\v11.0\SharePointTools
    • .. \Program Files\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications
    • .. \Program Files\MSBuild\Microsoft\VisualStudio\v11.0\Web
    • .. \Program Files\MSBuild\Microsoft\Workflow Manager\1.0

(For 64-bit systems, use "\Program Files (x86)" in the path above.)

  • Install Workflow Dependencies to the GAC
  • Microsoft.Activities.Design.dll

The file is located in the following folder on the development system:
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\

Configure Jenkins to build the SharePoint project

Ensure that you are able to build the SharePoint projects using MS build command line tool.  If successful, create Jenkins workspace for building the SharePoint project using MS Build commands.  Refer to the Jenkins documentation on the steps to do that.

Installing Jenkins

  1. Pre-requisites:

The first thing you will need to install on your machine is Java. Jenkins is a Java web application, so you will need at least the Java Runtime Environment, or JRE to run it. To check whether java is already installed in your machine or to know the version of Java type the below lines in command prompt

java –version

  1. You can either install Jenkins using war file or as a service.
  2. Extract the Zip file and the run the setup.           
  3. Installation wizard is opened as shown below. Click Next.

Image 1

  1. Select the destination folder where the Jenkins has to be installed and click next.

Image 2

  1. Then click install.

Image 3

  1. After installation is complete click Finish.

Image 4

  1. Now you can see the Jenkins Page in the URL http://localhost:8080/
  2. Go to Manage Jenkins->Manage Plugin->Advanced.
  3. Enter the proxy details(if a proxy is used to connect to the internet) and click submit.

 

Configuring Jenkins

In this section we will explain how to install and configure FxCop Plugin to invoke FxCop(BizTalkCop) rules from Jenkins for a BizTalk project. The steps for configuring are:

  1. Adding FxCop & SVN Plugin to Jenkins
  2. FxCop Configurations
  3. Adding a project into Jenkins from SVN
  4. Building Application from Jenkins
  5. Workspace & Changes

1)Adding FxCop & SVN Plugin to Jenkins:

  1. Go to Manage Jenkins->Configure System. Check whether configurations for FxCop and sub version are available.                                                                                                                                                               Image 5  Image 6
  2. In this case we have configurations for SVN to be listed and configurations are not listed for FxCop. Now we have to install FxCop.
  3. Go to URL: updates.jenkins-ci.org/download/plugins. List of plugins available in Jenkins will be listed.            Image 7
  4. Click fxcoprunner/ plugin and download the latest .hpi file.                                                                                Image 8
  5. Then go to Manage Jenkins->Manage Plugins->Advanced
  6. In the upload Plugin select the .hpi file downloaded and click submit.                                                               Image 9
  7. Now the plugin is installed and you can see the fxcop configurations in the system configuration                       Image 10

2)FxCop Configurations:

  1. Install FxCop and BizTalkCop in your system.
  2. Use the setup files to install Fxcop and BizTalkCop - FxCopSetup_1_36.exe/BizTalkCop_1.0.0.1.msi                 
  3. First install FxCop and then install BizTalkCop. Installing BizTalkCop will add BizTalkCopRules.dll into Rules folder in Fxcop.
  4. Go to Manage Jenkins->Configure System. Add FxCop installations                                                                  Image 11
  5. Enter a name for FxCop plugin and give the installation path of FxCop Plugin. Click Add FxCop and click Save.
  6. FxCop Configurations are done. Follow the same procedure for installation of other plugins too.

3)Adding a project into Jenkins from SVN:

  1. Select New Item. Options for including the project into Jenkins are displayed. Select  the type of project(here we will select freestyle project), enter the name of the project to be displayed in Jenkins. Click OK.                                                                                                                                                                        Image 12
  2. Under Source Control Management select Subversion and enter the repository URL                                        Image 13
  3. Under Build Trigger select POLL SCM and in schedule enter the polling interval. We have specified the schedule in the below figure as 5 mins. 
  4. Under Build, select ‘Add Build step’ button, and select FxCop exec in the dropdown. Now enter the FxCop plugin details. Here we have given build step as command line arguments.                                                      Image 14
  5. The command line argument given:                                                                                                                      
    BAT
     /d:"C:\Program Files (x86)\Microsoft FxCop 1.36\FxCopCmd.exe" /file:"%WORKSPACE%\OrderProcess\bin\Deployment\OrderProcess.dll" /rule:"C:\Program Files (x86)\Microsoft FxCop 1.36\Rules\BizTalkCop.Rules.dll" /out:"D:\OrderProcess\OrderProcess\FxCop_Result.xml"                                   
    Installation Path of Fxcop: "C:\Program Files (x86)\Microsoft FxCop 1.36\FxCopCmd.exe"     Project dll:  "%WORKSPACE%\OrderProcess\bin\Deployment\OrderProcess.dll".                                                                   This dll is picked from the Jenkins  workspace.                                                                   Installation Path of BizTalkCop: "C:\Program Files (x86)\Microsoft FxCop 1.36\Rules                                                                                             \BizTalkCop.Rules.dll"                                                                   Path where the report has to be placed:"D:\OrderProcess\OrderProcess\FxCop_Result.xml"                                                                                                                                                                                                                                                                                  
  6. Then select “Add Build Step” under Build and select “Build a visual studio project or solution using MSBuild”.
  7. Select the name of the MSBuild plugin from the list available and give the command line arguments as given below:                                                                                                                                                            
    BAT
    MSBuild.exe "D:\BAM\BAM\BAM TrainingLabFiles\OrderProcess\OrderProcess.sln"                              Path of the solution file: "D:\BAM\BAM\BAM TrainingLabFiles\OrderProcess\OrderProcess.sln"
  8. Else you can select the MSBuild plugin name and give the path of the solution file as shown below                Image 15
  9. Click Save.

4) Building Application from Jenkins:

  1. To build an application click on the project in the dashboard and click Build Now.                                            Image 16
  2. Build report can be seen from the build history. Inside the build history click on the arrow near the build and click console output.                                                                                                                                      Image 17
  3. Here you can see the console ouput.                                                                                                                    Image 18

5)Workspace & Changes:

  1. To view the entire code click on the project->workspace.                                                                                    Image 19
  2. To view the change history, select the project and click changes.                                                                        Image 20

 

Setting up of Jenkins for TFS projects

This section describes the procedure to setup the Jenkins tool specifically for building projects from TFS.  In addition to retrieving the source code from TFS, BizTalk projects are validated using BizTalk Cop rules for an automated code review and results are written in a configured output path. 

Following are the various steps that are involved in creating a project in Jenkins.  More details are provided under each of the items mentioned. 

Pre-requisites: Before going through this, ensure that all the pre-requisites for building BizTalk and SharePoint projects should be installed and the machine should be ready.

Steps to set up project in Jenkins:
1.    Install and configure TFS plug-in
2.    Install and configure FxCop plug-in
3.    Create global environment variables to be used in the projects
4.    Create project in Jenkins that builds using msbuild command line
5.    Configure TFS source location for the project
6.    Configure FxCop command line for BizTalk Cop rules validation
7.    Setup the build schedule for periodical builds
8.    Specify users to receive emails in case of failures
9.    Specify upstream and downstream projects to maintain project build order

1.      Install and configure TFS plug-in

Go to Manage Plug-ins link from Jenkins and install the TFS plug-in.  

Image 21

After installation, the TFS Plug-in will appear in the Installed tab as above. 

Go to Manage Jenkins -> Configure System page to configure TFS settings. 

Under Team Foundation Server, specify the TFS command line executable path.  Eg. C:\TEE-CLC-12.0.2\tf.cmd

Now the TFS plug-in should be installed and configured and the TFS source can be accessed from the Jenkins build project.

2. Install and configure FxCop plug-in

After installing FxCop plug-in as mentioned in the link in the step 1, the FxCop plug-in should appear in the installed plug-ins tab. 

In the Configure System page, under FxCop installations, give the path of the FxCopCmd executable, so that it will be used by Jenkins during build process.  See below for the path specification in the configuration page.  

Image 22

3. Create global environment variables to be used in the projects

We can create global variables to be used across all the Jenkins projects.   We have created few variables for specifying the Workspace paths, and the path where the BizTalk cop results are written.  We can create any other necessary environment variables which might be commonly used in multiple projects.  

Image 23

4. Create project in Jenkins that builds using msbuild command line

Create a new Free Style project and specify the name which is same as the project name in BizTalk.  This will enable us to use the JOB_NAME variable in our commands and configurations.  If we want to create a new project, there is an option ‘Copy Existing Item’ where we can specify the project whose settings will be used initially.  This can be easily modified as per the new project.  

Image 24Initial settings used in the project created:

 

Image 25

Click on the ‘Advanced Project Options’ and check ‘Use Custom Workspace’.  We have used custom workspace in order to build the projects in our specified location rather than using default location.  

Image 26

Add build step and specify ‘Execute windows batch command’. 

Specify the necessary commands to build the project in the Execute Windows Batch command window.  

Image 27

In msbuild command, /p:"ReferencePath" parameter can be used to specify dynamically the location of dll's which this built solution is dependent on.  

5. Configure TFS source location for the project

Specify TFS details under Source Code Management.  We need to give Server URL, Project Path, Login Name and User Password.

Image 28Now the Jenkins should take the code from TFS and invoke msbuild and do a build.  

5. Configure FxCop command line for BizTalk Cop rules validation

Add Build Step and FxCop Exec.  Select the ‘BizTalkCop’ from the dropdown for FxCop Name. 

Specify the following in the command line arguments:

BAT
/file:"%WORKSPACE%\%JOB_NAME%.Pipelines\bin\Release\%JOB_NAME%.Pipelines.dll"

/rule:"C:\Program Files (x86)\Microsoft FxCop 1.36\Rules\BizTalkCop.Rules.dll" 

/out:"%BizTalkCopOutPath%\FxCop_Result_%JOB_NAME%.Pipelines.xml" 

/directory:"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies\Microsoft.XLANGs.BaseTypes.dll" 

/directory:"C:\Program Files (x86)\Microsoft BizTalk Server 2009\Microsoft.XLANGs.BizTalk.ProcessInterface.dll"

/file – Path of the Dll file to be validated by FxCop

/rule – Path of the BizTalkCop.Rules.dll

/out – FxCop Result path

/directory – Directory where any dependent assemblies are present

Similarly add more build steps for validating additional BizTalk dlls like Maps, orchestrations etc and modify the properties in the command line arguments accordingly.  

Image 29Now TFS, msbuild and BizTalk Cop rules are configured.  If we click on ‘Build Now’ the project should get built, taking the latest code from TFS.  

7. Setup the build schedule for periodical builds

The project can be scheduled to be built daily, by specifying ‘@daily’ in the ‘Build Triggers’ section by checking the ‘Build Periodically’ checkbox.  

Image 30It will be built on a daily time schedule chosen by Jenkins.                                                                                   8. 8.Specify users to receive emails in case of failures

<o:p>You can specify users to send error alert emails in case of build failures for the projects.  In the ‘Add Post Build Action’, choose Email Notification.  Enter the list of usernames who wish to be notified separated by space.  

Image 31

9. Specify upstream and downstream projects to maintain project build order

In order to build multiple projects and enforce order of building projects, we  need to use UpStream and Downstream projects.  A downstream project is a project that will be built after the current project is built.  An Upstream project will be built before the current project is built.  For upstream project, you need to specify the project in the ‘Build Triggers’ section.  

Image 32For the downstream project, specify in the ‘Post Build Actions’ and ‘Build Other Projects’

Image 33

See screenshots.  The build order for these 3 projects in this case will be:

  1. msbuildtest
  2. OrderProcess
  3. sampleSVNTest

In this way, we can specify the build sequence for the entire set of projects.  

Image 34

Summary

Explained about the Setup of Jenkins and building a project using that. Used SVN and TFS to configure Jenkins for periodic builds.  Also saw how to send error emails on failures.  Build sequence can be specified for a set of projects.  

History

Keep a running update of any changes or improvements you've made here.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)