Skip to content
  • Services
    Our Approach
    Personalized, in-depth technical guidance on a global scale that helps organizations achieve their digital transformation goals.
    Learn more
    • Our Approach
    • Development
    • Design
    • Digital Experience Platform
    • Data & Analytics
    • Cloud & DevOps
    • Support
  • Work
    Our Work
    Through our expertise in strategy, design, and engineering, we help clients deliver digital transformation at scale.
    Learn more
    • Our Work
    • Healthcare
    • Finance
    • Manufacturing
    • Agriculture
    • Education
  • About
    About us
    For over 20 years, we’ve partnered with companies of all sizes and industries to solve their most complex business problems.
    Learn more
    • About us
    • Leadership
    • Locations
    • Events
    • News
  • Careers
    Join our Team
    Take your career to the next level. We offer exciting opportunities across every stage of the software development life cycle.
    Learn more
    • Join our Team
    • Open Positions
    • Application Process
    • Benefits
    • Learning & Development
  • Insights
    Our Insights
    Read our latest blogs, watch our recent videos, and browse our library of e-books — all full of insights from our experts.
    Learn more
    • Our Insights
    • Blog
    • Videos
    • Downloads
  • Contact
Menu

Jenkins CI in MVC.NET Part 1: Install, Setup and Build

More on companies’ integration of continuous integration servers in their work process and their benefits.

Annika Hey

Annika Hey

Design Principal

Atanas Atanasov

Atanas Atanasov

Software Development Manager – Agile Frameworks

Björn Stansvik

Founder & Chief Executive Officer

Daniela Nazim

Daniela Nazim

MentorMate Alumni

Dimitar Dobrev

Dimitar Dobrev

MentorMate Alumni

Craig Knighton

Chief Operating Officer

Eleonora Georgieva

Global VP, Delivery

Georgi Dormishev

George Dormishev

System Administration Manager

Ivaylo Kostadinov

Director, Software Engineering - .NET

Jamie Bolseth profile picture

Jamie Bolseth

MentorMate Alumni

Jay Miller

President

Jeni Kyuchukova

Director, Quality Engineering

Jessica Anderson

VP of Finance and Administration

Liz Spolyar

Global Director, Continuation Engineering

Nick Curran

Nick Curran

Technical Architect

Nikolay Lyubchev

Global Director, Talent Acquisition, MentorMate

Stefan Tsvyatkov

Director, Software Engineering - Mobile

Stefan Tzanev

Chief Financial Officer

Vesselin Dobrev

Vesselin Dobrev

General Manager (Bulgaria)

Sylvia Vassileva

Sylvia Vassileva

Software Development Manager - Spok

Filip Gajtanovski

Software Development Manager - Storyworks

Krasimir K. Nikolov

VP of Technology

Katherine Kelly

Director of Operations (USA)

Carrie Siewert

Strategic Account Manager

Brady Swanson

Global Director, Marketing

Eve Poeschl

MentorMate Alumni

Ryan Peña

MentorMate Alumni

Vassil Vassilev

Software Development Manager - .NET

Pavel Petrov

Director, Software Engineering - LAMP&FE

Ivan Peev

Senior Technology Manager

Bob Reuss

MentorMate Alumni

Vera Kasapova

QA Manager

Greta Yamacheva

QA Manager

Robert Samuelsson

General Manager (Sweden)

Kyle Simmons

Solutions Architect

Robin Thomas

Solutions Architect

Nataliya Naydenova

MentorMate Alumni

Adam Malone

Alexander Dimitrov

Enterprise Architect

Andrea Kates

CEO, LaunchPad Central

Andrew Eklund

CEO, Ciceron

Andrew Marinov

Angel Nikolov

MentorMate Alumni

Anurag Shukla

Aron Wolde

MentorMate Alumni

Ashley Goodridge

Office Assistant

Benjamin Gramlich

MentorMate Alumni

Chris Black

MentorMate Alumni

Christa Haeg

MentorMate Alumni

Colin Lee

MentorMate Alumni

Deyan Stoynov

MentorMate Alumni

Dimitar Danailov

MentorMate Alumni

Dobrinka Tabakova

Doug Leatherman

Emily Genco

MentorMate Alumni

Fanka Vassileva

Gabriela Zagarova

MentorMate Alumni

Gary Conkright

CEO, physIQ

Gary Fingerhut

Executive Director, Cleveland Clinic Innovations

Gavin Finden

MentorMate Alumni

Georgi

Graham Klang

Hyusein Hyuseinov

Senior Automation QA

Ian Good

Global VP, Operations

Iva

Jack Cosentino

James Williams

John Byrne

Kaloyan Stoilkov

MentorMate Alumni

Kosta Hristov

Krasimir Gatev

Senior Android Developer

Lazar Petrakiev

Lyubomir Dobrev

Senior .NET Developer

Lubomir Velkov

Marin Yotovski

Mark Smith

MentorMate Alumni

Martin Dimitrov

MentorMate Alumni

Martin Kalyonski

Mike Hagan

MentorMate Alumni

Nikolay Andonov

Nikolay Arhangelov

Riley Panko

Guest Contributor

Roger Ferguson

MentorMate Alumni

Ryan Sysko

Chairman, WellDoc

Ryan Blake

MentorMate Alumnus

Sarah Rockholt

MentorMate Alumni

Sean McDevitt

CEO, Sensei

Siyana Slavova

Stanislas Walden

MentorMate Alumni

Stanislav Atanasov

Stanislava Bogdanova

MentorMate Alumni

Stefanie Trimble

MentorMate Alumnus

Stephen Fluin

Stoyan Stoyanov

MentorMate Alumnus

Tessa Cacek

Staffing Manager

Tom Clemens

MentorMate Alumnus

V8 JavaScript Engine

Viktor Mitev

Yolanda Petkova

Marketing Design Lead

Pete Anderson

Lead Product Owner, Target

MentorMate Software Development Lead Vasil Nonchev

Vasil Nonchev

Java Software Development Manager

Dilyana Totseva

QA Manager

Stanimir Nikolov profile picture

Stanimir Nikolov

Software Development Lead - iOS, MentorMate

Rosen Kolev

Technology Principal

Dimitar Mihaylov

MentorMate Alumni

Nikola Genov

Software Architect - .NET

Neli Todorova

Software Development Manager - LAMP

Yavor Dimitrov

MentorMate Alumni

Georgi Karanedyalkov

Software Development Lead - Android, MentorMate

Denislav Ganchev

Technology Principal

Stefan Shopov

QA Manager

Konstantin Rusev

Java Developer

Borislav Dimitrov profile picture

Borislav Dimitrov

Senior Android Developer, MentorMate

Tsvetelina Lazarova

MentorMate Alumni

Dimitar Gadzhev

Developer

Plamen Stoev

Software Development Manager - Front-end

Jake Nelsen

Senior Experience Designer

Zlati Pehlivanov

Zlati Pehlivanov

Senior Software Engineer II

Kate Tolmie, MentorMate Senior UX Designer

Kate Tolmie

Senior Experience Designer

Martin Angelov

Director, Software Engineering - LAMP&FE, MentorMate

Dimitar Zhelev

Senior .NET Developer

Joel Swenson, MentorMate Content Writer

Joel Swenson

Content Manager

Kiril Ivanov

Quality Assurance Analyst

Viktor Hristoskov profile picture

Viktor Hristoskov

Software Development Lead - iOS, MentorMate

Violeta Nikolcheva

Database Developer

Biliana Kadakevlieva

Senior Quality Assurance Analyst

Chris McLeod

Senior Solutions Consultant

Antonii Georgiev

Junior .NET Developer

Alexander Rusev

Front-End Developer

Matt Erickson, MentorMate PR and Social Media Manager

Matt Erickson

MentorMate Alumni

Brian Buchkosky

Global Director, PMO

David Tran, MentorMate VP of Solutions

David Tran

MentorMate Alumni

Kristin Krueger

MentorMate Alumni

Magdalena Chervenkova

Business Analyst

Denny Royal

Chief Design Officer

MentorMate Technical Account Strategist Joe Bodell

Joe Bodell

MentorMate Alumni

Viktoriya Chuchumisheva - MentorMate HR Manager

Viktoria Chuchumisheva

HR Manager

Kalina Tekelieva Headshot

Kalina Tekelieva

Senior Content Marketing Artist

Daniel Rankov profile picture

Daniel Rankov

MentorMate Alumni

MentorMate Senior Business Analyst Alexander Alexandrov

Alexander Alexandrov

BA Lead

MentorMate

Clint Rowles

VP, Business Development

Nikola Donev - SysAdmin

Nikola Donev

SysOps & DevOps Lead

Tseko Tsolov

Frontend Developer

Denislav Lefterov

Automation QA Analyst

MentorMate Content Writer Dilyana Kodjamanova

Dilyana Kodjamanova

MentorMate Alumni

MentorMate Project Manager Emma Jorstad

Emma Jorstad

Project Manager, Lead

Georgi Georgiev profile picture

Georgi Georgiev

Software Development Lead - LAMP, MentorMate

Martin Panayotov profile picture

Martin Panayotov

Senior iOS Developer, MentorMate

John Blake

John Blake

Senior Account Manager

Tyler Compton

Tyler Compton

Solutions Architect

MentorMate Software Developer Nikola Peevsk

Nikola Peevski

Software Developer — Lamp & Front-End

Aaron Whitney

Director of Client Strategy

MentorMate Senior Cloud Engineer Veliko Ivanov

Veliko Ivanov

Senior Cloud Engineer

MentorMate Senior Project Manager Suzanne O'Brien

Suzanne O’Brien

Senior Project Manager

Svetlin Stanchev profile picture

Svetlin Stanchev

Software Development Lead - Front-end, MentorMate

MentorMate Senior Cloud Engineer Todor Todorov

Todor Todorov

Senior Cloud Engineer

MentorMate Senior QA Analyst Kate Stamatova

Kate Stamatova

Senior QA Analyst

Frank Anselmo profile pic

Frank Anselmo

Global Director, Project Management

Gyuner Zeki Headshot

Gyuner Zeki

Solutions Architect

Galin Stanchev

QA Analyst

Sarah Hoops

Business Development Manager

Brenden Diehl

Business Development Manager

Anna Krivova profile picture

Anna Krivova

Software Development Lead - Front-end, MentorMate

Ivelina Kavalova profile picture

Ivelina Kavalova

Senior Business Analyst, MentorMate

Paul Sanders

MentorMate Alumni

Jim Cikanek

Senior Client Strategist

Samuil Yanovski profile picture

Samuil Yanovski

Software Development Manager - Android, MentorMate

Krasimir Gatev profile picture

Krasimir Gatev

Senior Android Developer, MentorMate

Kristina Goryalova headshot

Kristina Goryalova

Talent Acquisition Manager

Elena Petrova Headshot

Elena Petrova

HR Specialist

Jay Matre

Senior Business Architect, MentorMate

Lilyana Dimitrova

QA Specialist

Josh Marquart

Chief Strategy Officer

Mario Gorki

Senior Mobile Developer

Simeon Zhekov Headshot

Simeon Zhekov

Cloud Engineer

Hristo Stoyanov Headshot

Hristo Stoyanov

Cloud & DevOps Lead

Ben Wallace

Enterprise Architect

Boyan Stoyanov

Data & Dota Specialist

MentorMate Director of Software Engineering Petya Ivanova

Petya Ivanova

Director, Software Engineering - Java

Sebastian Ortiz-Chamorro

VP of Engineering, Latin America

Consuelo Merino profile pic

Consuelo Merino

Director of Operations

Continuous integration is widely used term today. The main reason for this is because more and more companies are integrating continuous integration servers in their work process. The benefits of this can be many. From faster issue detection, quick builds and deploys, project risk management, open tasks track, etc. All benefits and good practices can be found in books like “Continuous Integration” by Paul Duvall, Steve Matyas, and Andrew Glover or “Continuous Delivery” by Jez Humble and David Farley. For that reason there is a lot of tools created to resolve this tasks. Tools like “Team Foundation Server” and “Bamboo” have good integrated solutions, but they are paid and not all companies are willing to use them. Another alternative is Jenkin CI which is pretty popular mainly because it is very flexible and can perform wide array of tasks. But this flexibility come with the price, that it is not very easy to setup. So in series of blog post I will try to present to you a fairy common and complete setup of Jenkins continue integration process for a single MVC.NET application. The first step is installing the server itself under windows, adding some required plugins and tools in order to build .NET application and creating a new Job that build our application.

Installing

  1. Go to jenkins-ci.org download and install Jenkins for Windows. After the setup finish it will automatically start it.
    Note that IIS is not required. Jenkins will run its own server.
  2. Visit the https://microsoft.com/en-US/download and install the latest version of Windows Software Development Kit. Last location is here.
  3. Go to your Jenkins manage page and make sure the Subversion plugin and/or the Git plugin are installed, so you can download your projects.
    • In order to install git plugin you need to download git itself first. Go to http://git-scm.com/download and download the latest version.
    • After you install git plugin you will need to set the Git location in the configuration. Example under git installations you may enter Name: “Default” and Path: “c:/Program Files (x86)/Git/bin/git.exe” if this is where you installed git.
    • Git plugin install ‘ssh credentials’ plugin. It is a good idea to crate a ssh user what jenkins is going to use when connecting git. When using the plugin place your .ssh folder on the main drive root (Example c:.ssh).
  4. Go to the Microsoft download page and download the latest “Microsoft build tools” and install it. The ‘Microsoft build tools’ include MSBuild. After the install in the “Program Files (x86)” folder you should have MSBuild folder.
  5. Go to System -> Advanced system settings -> Environment Variables and set the PATH to point to the MSBuild folder (ex: C:Program Files (x86)MSBuild14.0Bin). After Path is set you need to restart jenkins. You can do this by navigating to “YourJenkinsDomain/restart” page.
  6. Download the NuGet executable. This tool is used to restore NuGet packages used by the project. NuGet is available at http://nuget.org/nuget.exe.
    It is good idea to hold all tools in one folder so with our example we will use c:Tools to hold all required tools. So the NuGet executable cab be in the ‘c:ToolsNuGetNuGet.exe’

Setup Git

I think the best way to use continuous integration with git is to set all developers users to pull from the master branch, but not to be able to push to it. The only user that will be able to push to the master will be Jenkins. In this way on the master branch will always be a stable version and the developers will not use broken builds. This flow will look like this:
  1. [You] Pull from master.
  2. [You] Create new branch and make changes.
  3. [You] Rebase with master and push to origin premaster (Push to master will not be allowed).
  4. [CI] Get the latest version from premaster branch.
  5. [CI] Build, run test and analyzes tools.
  6. [CI] Merge with master.

With this scenario on the master branch resign only stable build version. If  QA or client require a new build version to be deployed to the test server this can be initialized with a stable build, although component or functional test can be run at this point.

Unfortunately, revoking write permissions to master is not possible in Github (It is possible in GitLab by making the master branch protected). We may use other git servers to manage this scenario.

Some example config in ‘gitolite’ can be:

@all-devs = alice bob carol
@ci       = jenkins
@admin    = supermen

repo test
    RW+                = @admin
    RW    master$      = @ci
    RW    premaster$   = @all-devs
    RW    refs/heads$  = @all-devs
    R     master$      = @all-devs

With this configuration the users Alice, Bob and Carol can modify the branches and the premaster origin, but can only read from the master. The Jenkins user however can modify the master.

Using Git on Developer Machine

Let we assume I am “Alice” and I want to start using git and Jenkins in my project. When I clone a repository I can start pulling from the master branch and create branches out of it, but I can not push to the master branch. I need to push to a premaster branch (The branch that Jenkins track) after a change is made.

Setup Git at Jenkins

In order to make sure Jenkins is up and running we can make it build a project and push it to master.

  1. Go to Jenkins page and Go to ‘New Item’.
  2. Enter a name and select a project type (Freestyle project is ok for the test).
  3. On the ‘Source Code Management’ section choose Git (if you use another VCS setup it here). Set the repository path and credentials.
    • If you use gitolite you can reference this.
    • If you use gitlab you can install the gitlab plugin and use that.
  4. Check ‘Poll SCM’. This option will allow Jenkins periodically to check for new commit in version control system. For example ‘H/10 * * * *’ will check for new version every 10 min.
  5. At ‘Add post-build action’ select ‘Git Publisher’.
    Check Push Only If Build Succeeds.
    Add Banch origin master to push to.

You can at this point try to push something to the repository and check if it is merged to master branch.

Setup SVN

Setup for SVN is straightforward it do not allow update from one branch and commit to another so the only thing you do is update.

Build a project with Jenkins

  1. Create a project
    • File => New => Project => ASP.NET Web Application.
    • Set some name, for example: “FirstBuild”.
    • Select the version control folder.
    • From the templates select MVC.
  2. First thing to do is to clean the project if there is some files left from old build. If you use the (Default) option MSBuild may find the solution file by itself. Otherwise you have to specify Build File.

    MSBuild Build File:                     ${WORKSPACE}FirstBuild.sln
    MSBuild Command Arguments: /t:Clean /v:m /nologo

    As extra clean you can use bash script that delete all bin and obj folders in the projects.

    Jenkins CI MSBuild Clean
    Jenkins CI MSBuild Clean
  3. After the clean we need to restore all NuGet packages. You do this with a bash script and accessing NuGet.exe.
    If your solution is named FirstBuild and you have installed NuGet at the specified folder you can execute the fallowing Bash script to restore your libraries.
    REM "Restore libraries."
    "C:ToolsNuGetNuGet.exe" restore FirstBuild.sln
  4. Building the project with MSBuild. We can use the options:
    • /t:Build – start a build.
    • /p:Configuration=Debug – build in Debug mode. Use can build in Release mode, also.
    • /v:q – sets the verbosity to quit so the log not to be poluted with too much information.
    • /nologo – remove the some unneeded information from the log file.

    MSBuild Command Arguments: /t:Build /p:Configuration=Debug /v:q /nologo

    Jenkins CI MSBuild Debug
    Jenkins CI MSBuild Debug
  5. Before you build it you must remove from all web project (.csproj) files the Visual Studio targets paths. Open project files with text editor and remove the “PropertyGroup” above Imports. It should look like this:
    <PropertyGroup>
        <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
        <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)MicrosoftVisualStudiov$(VisualStudioVersion)</VSToolsPath>
    </PropertyGroup>

Post-build Actions

As extra post-build actions you can use the fallowing plugins

  • Task Scanner Plugin
    Plugin that scan for open task. In order to scan for tasks you need to specify a file scan pattern. This is one example that scan all .cs files and the javascript files in the “Scripts” folder, except the modernizer and jquery.

    Files to scan:      **/*.cs, FirstBuildScripts*.js
    Files to exclude: FirstBuildScriptsmodernizr-2.6.2.js, FirstBuildScriptsjquery-2.1.1.js

  • Worksplace Cleaner Plugin
    The plugin can clean up the workplace after build finish.
    If you use this plugin and remove the /obj and /bin folders, MSBuild cleanup is not required.

References

  • http://www.yegor256.com/2014/07/21/read-only-master-branch.html
  • http://devsops.blogspot.com/2013/01/gitlab-jenkins-and-puppet-playing.html
Tags
  • Development
  • Security
Share
  • Share on Facebook
  • Share on LinkedIn
  • Share on Twitter
Share
  • Share on Facebook
  • Share on LinkedIn
  • Share on Twitter
Sign up for our monthly newsletter.
Sign up for our monthly newsletter.

Read what's next.

Blog

How to Write Effective Technical Tasks and User Stories

Blog

Measuring the Business Value of Technology Investments

  • Twitter
  • LinkedIn
  • Instagram
  • Facebook
United States
MentorMate1350 Lagoon Ave, Suite 800
Minneapolis
, MN 55408

+1 612 823 4000
Bulgaria
67 Prof. Tsvetan Lazarov Blvd.
Sofia 1592, Bulgaria,
+359 2 862 2632
Sweden
Drottninggatan 29
411 14 Göteborg

+46 3 199 0180
Paraguay
Carlos M. Gimenez 4855
Asunción, Paraguay

+595 21 327 9463

Copyright © 2023 MentorMate, Inc.

  • Cookies
  • Privacy
  • Terms
  • Continuity Policy
This site is registered on wpml.org as a development site.