I have used Jenkins for applications based on Java, OSB, PHP, Node JS, etc running on Linux/Unix platforms. Recently I got a chance to work on Windows platform for build and deployment of .NET applications using Jenkins and Octopus.
This article covers following points:
- Checkout code from Git
- Build the code
- Package the code
- Push to Octopus for deployment
Once the code is pushed to Octopus, Jenkins job finishes and you can login to Octopus server deployment. I will cover the setup of Octopus in a separate article.
- Install Slave on the Windows build server. This is not the server where deployment will happen, rather this is build server. You can install Octopus on the same server if required.
Installation instruction can be found here for Jenkins slave setup.
- Now create a Job on Jenkins master server which will run on slave. Let’s call Jenkins slave as ‘octo’. This is just a label to identify slave server. Also, I am using latest release of Jenkins with JDK 1.8. This is how first part of the job looks like.
- Now add the Git repository with appropriate credentials. I have added dummy detail in below snapshot that’s why there is error reported.
- Once code is checked out we will build it. It will require MSBuild plugin to be installed in Jenkins. It will also require nuget executable to be installed on slave server.
- MSBuild runner needs to be configured on the Jenkins master server. Go to Manage Jenkins > Global Tool Configuration and then configure MSBuild runner as shown below:
The path specified above must be present on your slave server, which is actually used as a build server.
- Now go to “Build” section of this job and select “Build a Visual Studio project or solution using MSBuild” option.
- Next step is to package your application using nuget command.
- The last step is to push the package created in above step to Octopus server. Here you have to specify details of your Octopus server like URL, API Key and also the package created in above step.
Once last step executed successfully, you can check the logs and it will look like this:
I hope it will be useful for everyone out there who want to use Jenkins for auto deployment of .NET applications. Please feel free to contact me if you have any question.