Quick overview of how to set up Jenkins and Git for automated deployment of applications to Microsoft Internet Information Services (IIS) web server.

Install Jenkins and necessary components

  1. Install Jenkins
  2. The Jenkins box needs Visual Studio installed. (Whichever version you're using to develop the project.)
  3. Fire up Jenkins at http://localhost:8080/ and, in the menu (left margin) choose "Manage Jenkins".
  4. Select "Manage Plugins", select the "Available" tab, and install the MSBuild and Github plugins. (These will pull in dependencies.) After the install, Jenkins will need to restart.

Configure a Jenkins Job

  1. Only keep the last 5 builds, as each one contains a full copy of the Git repository
  2. This does nothing for actually integrating with Github, it simply makes the "Github" link on the far left for quick-access to the repo

  1. Github Repository URL
  2. BuildBot user credentials (Use a github user that has Owner access to the repo so it can auto-generate the webhooks on Github.)
  3. Set the branch to use whichever one you want the job to "listen" to.
  4. If you're behind a firewall, it's difficult to try to get the Github server-side hooks to post to the Jenkins server. Instead, we poll Github and build whenever we find new commits. Note, the syntax in the image means poll every 2 minutes.

  1. The MSBUILD step requires a user for the MSDEPLOY part of the build process.
  2. The user is defined and recorded in the MSDEPLOY "Publish Profile" described below, but the password needs to be provided at run-time, so we accomplish that by providing the password in the build configuration and mask it using a Password Masking jenkins plugin
  3. Fancy build number instead of boring incrementing integer
  4. Use Nuget.exe to restore the .NET Nuget/package dependencies required for the build
  5. Execute npm install to restore NodeJs dependencies
  6. Execute npm build script to build the javascript dependencies for the web application.

  1. It's very easy to use the "Publish Profiles" generated by Visual Studio. Normally we could just add them directly to source, but since this one has a special need for using SQL Authentication instead of MS-SQL Integrated Security, we need it to store raw credentials and therefore we can't keep it in git. SO! We handle it outside of version control and copy it in at build time.
  2. MSBUILD Jenkins plugin
  3. MSBuild.exe parameters for building/deploying the app:
/P:VisualStudioVersion=14.0
/P:Password=${PASSWORD_1}           <-- References password from above
/P:AllowUntrustedCertificate=true
/P:DeployOnBuild=True
/P:PublishProfile=warehouse_test     <-- This is the Publish Profile we copied in
/P:DeployIISAppPath="Your App Name"    <-- This needs to match exactly the name on the target IIS deployment
/P:MsDeployServiceUrl=WEBSERVER   <-- Target deployment server. Must have Web Deploy 3.5 installed
/P:Configuration=Release