.NET Web CI with jenkins

  1. Install jenkins - https://jenkins.io/download/
  2. Install MSBuild plugin
    1. Navigate to Manage jenkins -> Manage plugins
    2. Navigate to Available
    3. Find MSBuild
    4. Select it and install it by selecting the option “Install without restart”
  3. If MSBuild.exe doesnot exist in server, download it.  https://www.visualstudio.com/downloads/
    1. Choose Other Tools and Frameworks->Build Tools for Visual Studio
    2. Download it and install it. (Select Build tools and .NET Dependencies)
  4. Setup MSBuild
    1. Navigate to Manage Jenkins -> Configure System
      1. Find MSBuild
    2. If it is not there, Navigate to Manage Jenkins -> Global Tool Configuration
      1. Find MSBuild
    3. Click on Add MSBuild
    4. Create a name. It is user defined.
    5. Add MSBuild.exe path
    6. Save the settings.
  5. Setup github
    1. Navigate to Manage Jenkins ->  Global tool configuration
    2. Find Git settings / Git installations
    3. Set git.exe path
    4. Save the settings
  6. Setup Github credentials.
    1. Navigate to Manage Jenkins -> Configure System
    2. Find Github
    3. To create credentials, click on “Advanced” button
    4. In Shared secret, click on Add-> select Jenkins
    5. It will open a pop up, enter your github username in Username field, and enter your github password in password field. And click on “Add” button.
    6. Click on “Manage additional Github actions” -> Convert login and password to token in Additional action.
    7. Select “From credentials” or “From login and passsword” radio button.
    8. Pick your credentials from drop down.
    9. And click on “Create token” button.
    10. Click on Add github server
    11. Create some name for the config
    12. Choose your credentials that you have created in “credentials” field.
    13. To make sure that it is configured properly, check it by clicking “Test connection” button.
    14. Save the changes.
  7. Create jobs
    1. Click on “Create new item”
    2. Push some name for the job
    3. And select Freestyle project
  8. Configure job - Source code management
    1. Select “Git” radio button.
    2. In Repository URL,  Feed your repository URL.
    3. In Credentials, feed or select your github credentials.
    4. In Branches to build, enter your branch name : “*/branch_1”
  9. Configure job - Build Triggers(To create scheduler)
    1. Select Poll SCM
    2. Enter your scheduler timing, which should look like crontab timer. Ex: to poll every minute enter “* * * * *”
  10. Configure job - Build
    1. To configure Nuget package manager to install dependencies.
    2. Download Nuget.exe (https://www.nuget.org/downloads) and move it any folder in Directory C.
    3. To install project dependencies, click on “Add build step” and select “Execute windows batch command”.
    4. In command field,
      1. <Nuget.exe path> restore <Project solution path>
    5. To build solution, click on “Add build step” and select “Execute windows batch command”
    6. In command field,
      1. <path to msbuild.exe> <solution file path> /t:Clean,Build
    7. To publish project to IIS,
      1. Click on “Add build step” and select “ Build a visual Studio project or solution using MSbuild”
      2. In MSBuildVersion field, fill it with value.
      3. In MSBuild Build file field, Enter your project file path(Ex. C:\test\test.csproj)
      4. In command line arguments,
        1. /p:DeployOnBuild=true /p:PublishProfile=<Your publish profile file name>
        2. For this, you should have publish profile file in your project.
  11. Now the project is ready.  You have to convert the build as application from iis.

Ref :

https://blog.couchbase.com/continuous-deployment-with-jenkins-and-net/

Comments