Continuous Integration and Delivery Setup Instructions - 18F/dol-whd-14c GitHub Wiki

Jenkins server configuration

  1. Install and setup Jenkins on your build server.
  2. When you first login to your jenkins server, you will be asked to create a project if do not already have an existing one. Choose "Freestyle Project".
  3. Install and enable AT LEAST the following plugins for your Jenkins instance: GitHub Branch Source Plugin, GitHub Integration Plugin, MSBuild Plugin, MSTest Plugin, and NodeJS Plugin.
    1. From your Jenkins Dashboard, click Manage Jenkins >> Manage Plugins
    2. Under the "Available" plugins tab, search for the plugins above and check the box next to the plugin you want to install.
    3. Click "Download now and install after restart" and wait for your Jenkins instance to restart
  4. Install necessary tools on Jenkins server
    1. Connect to your Jenkins instance via a remote desktop connection
    2. Download and install Visual Studio Build Tools on your Jenkins build server. Be sure to select the Visual C++ build tools, Web development build tools, .NET Core build tools libraries during installation.
    3. Download nuget.exe on your build server
    4. Download and install webdeploy
    5. Download and install "IBM Data Server Client Packages" special_35279_ntx64_dsdriver_EN.exe
    6. Install Visual Studio 2015 Community with Update 3
    7. Download and Install "IBM Database Add-Ins for Visual Studio" ibm_database_addins_for_visualstudio_v11.1.exe
  5. Configure your build tools by setting the locations for MSBuild and NodeJS
    1. Log back into your Jenkins server and navigate to your Dashboard. Click on Manage Jenkins >> Global Configuration Tool. Scroll down to the MSBuild section and click "MS Build Installations".
    2. Enter a name for your MSBuild installation.
    3. Enter the path to MSBuild.exe on your Jenkins server
      # Example
      C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin
      
    4. In the NodeJS section, click "NodeJS Installations"
    5. Enter a name for your NodeJS installation and check "Install Automatically"
    6. Choose a node version
    7. Finish configuring your build tools by clicking "Save" at the bottom of the screen
  6. Configure environment variables
    1. Navigate to Manage Jenkins >> Configure System
    2. In the "Global Properties" section, check "Environment Variables" and add your desired variables to the jenkins server.
  7. From your dashboard, click New Item and then select "FreeStyle Project". If you created a freestyle project in the second step, navigate to the freestyle project that you created by clicking on it in the dashboard.
  8. Configure your project to pull from GitHub
    1. Select "Git" as the source control management system in the Source Code Management section
    2. Enter the url to your GitHub repository (.git) that you want to link to Jenkins
    3. Enter the branch that you want to link to this FreeStyle Project
    4. In the Build Triggers section, select "GitHub hook trigger for GITScm polling".
    5. In the Build Environment section, select "Delete workspace before build starts".
  9. Create necessary build steps to build, test, and deploy your application. You can use the environment variables you set up previously.

DOL.WHD.Section14c.WEB project build steps

  1. NPM Build & Test steps
    cd DOL.WHD.Section14c.Web
    npm install && npm run deploy
    npm test
    
  2. WebDeploy
    "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:contentPath="%WORKSPACE%\DOL.WHD.Section14c.Web\dist" -dest:contentPath=%INT_UI_DEPLOY_URL%,username=%INT_UI_USERNAME%,password=%INT_UI_PASSWORD%,authType="Basic",includeAcls="False" -allowUntrusted -setParam:kind="TextFile",scope="\\env.js$",match="<api_url_for_jenkins>",value=%INTEGRATION_URL_API% -setParam:kind="TextFile",scope="\\env.js$",match="<reCaptchaSiteKey_for_jenkins>",value=%RECAPTCHA_SITE_KEY%
    

NOTE: the match attributes in the web deploy command correspond to values found in the src/deploy/env.js file with the DOL.WHD.Section14c.Web project. These values must be the same for the deployed application to work properly.

DOL.WHD.Section14c.API project build steps

  1. Restore nuget packages

    C:\nuget.exe restore DOL.WHD.Section14c.sln
    
  2. MSBuild

    /P:AllowUntrustedCertificate=true /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:DeployIISAppPath="DefaultSite" /p:PackageAsSingleFile=true /p:PackageLocation="C:\temp\web.zip"
    
    
  3. MSTest

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\mstest.exe" /resultsfile:"%WORKSPACE%\AutomationTestAssistantResults.trx" /testcontainer:"%WORKSPACE%\DOL.WHD.Section14c.Test\bin\Debug\DOL.WHD.Section14c.Test.dll"
    
  4. WebDeploy

    "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package="C:\temp\web.zip" -dest:auto,computerName=%INT_API_DEPLOY_URL%,username=%INT_API_USERNAME%,password=%INT_API_PASSWORD%,authType="Basic",includeAcls="False" -allowUntrusted -setParam:kind="XmlFile",scope="web\.config$",match="/configuration/connectionStrings/add[@name='ApplicationDbContext']/@connectionString",value=%DB_CONNECTION_STRING% -setParam:kind="XmlFile",scope="web\.config$",match="/configuration/appSettings/add[@key='ReCaptchaSecretKey']/@value",value=%RECAPTCHA_SERVER_KEY% -setParam:kind="XmlFile",scope="web\.config$",match="/configuration/system.net/mailSettings/smtp/network/@host",value=%SMTP_SERVER% -setParam:kind="XmlFile",scope="web\.config$",match="/configuration/system.net/mailSettings/smtp/network/@userName",value=%SMTP_USERNAME% -setParam:kind="XmlFile",scope="web\.config$",match="/configuration/system.net/mailSettings/smtp/network/@password",value=%SMTP_PASSWORD% -setParam:kind="XmlFile",scope="web\.config$",match="/configuration/system.net/mailSettings/smtp/network/@port",value="465"
    
    

Target deploy server (api, ui, db)

NOTE: You must enable incoming traffic for ports 443(https), 80(http), 8172 (Web Deploy), and 3389 (RDP)

  1. Add the IIS Role to the target deploy server; adding Internet Information Services (IIS) and various connected components to a server turns it into a Web Server. This needs to be done in order to run web applications on the server.
    1. Connect to your target deploy server through a remote desktop connection
    2. Server Manager will open when you log in, click on "Add roles and features" near the top
    3. Click "Next"
    4. Make sure "Role-based" or "feature-based" installation is selected and click Next
    5. Make sure "Select a server from the server pool" is selected and click Next
    6. Select "Web Server (IIS)" from the list of Roles
    7. Click "Add features" from the new window
    8. Click "Next" on the next 4 screens, then click Install
    9. Wait until installation is complete, then click Close
  2. Install Web Deploy and URL Rewrite on the target deploy server
    1. Disable IE Enhanced Security Configuration by clicking on "Local Server" in the Server Manager, then click "On" next to the setting and change the setting to off for administrators
    2. Open the charms on the right side of the screen and select search, then type in Internet Information Services, click on the result in the list (this will open Internet Information Services (IIS) Manager
    3. Click on the triangle to the left of the VM listed in the Connections Menu
    4. When the popup asks if you would like to stay connected with the latest Web Platform components, click Yes. This will open the site to install the Web Platform Installer. Click on the Free Download button and run the installer.
    5. In the search bar for the Web Platform Installer type "Web Deploy"
    6. Click "Add" for all three of the Web Deploy 3.5 components, click install, and accept the terms of use, then wait for the install to complete
    7. In the search bar for the Web Platform Installer type "rewrite" and install the URL Rewrite component
  3. Install necessary DB2 packages
    1. Download and install "IBM Data Server Client Packages" special_35279_ntx64_dsdriver_EN.exe
  4. Reboot the VM

NOTE: see the respective Wiki page for setting up a working SMTP server on your windows machine with SendGrid