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