Press "Enter" to skip to content

How to publish ASP.NET Core application by using Jenkins

Tahmini okuma süresi: 12 dakika

In this article, i will describe how to publish ASP.NET Core application by using Jenkins. Since the subject of the article is about preparing pipeline, you can benefit the link below for the installation of Jenkins.

Because the target machine on which we will make deployment in our scenerio and the machine in which Jenkins has been installed will be different , we need to arrange a dedicated server for Jenkins. The reason is that the Jobs could deplete your resources while they are working.

The pipeline is made of the following 4 steps.

Checkout: Pull the source code from the Github
Build: Build the source code
Deploy: Deployment to the target machine

Before preparing the pipeline, you need to fulfil the requirements below.

1. The installation of the Git
In order to get the checkout done, the Git need to be installed in the Jenkins machine. You can install the Git by using the address below.

2. The installation of NET Core SDK
To make the build, NET Core SDK need to be installed in the Jenkins machine. By using the address below, you can install the relevant SDK according to the version in your application.

3. The installation of the MsDeploy in the Jenkins machine
To deployment, the msdeploy need to be installed in the Jenkins machine. For this, you can download the relevant installment from the address below.

4. The introduction of the trusted machine
If the Jenkins machine and the target machine are not in the same domain, the deployment from the Jenkins machine to the target machine can’t be done. There will be an error like below.

Connecting to remote server 0.0.0.0 failed with the following error message : The WinRM client cannot process the request. If the authentication scheme is different from Kerberos, or if the client computer is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setting.

To solve the error, you need to indicate to Jenkins that the target machine is trusted. For this, you can apply the command line below in the Powershell.

winrm set winrm/config/client '@{TrustedHosts="0.0.0.0"}'

5. The installation of the Web Management Service
To deployment remotely to the target machine, Web Management Service need to be installed and to be running in the IIS. Open the IIS to check whether the service has been installed. Choose your server from the connections window on the left. Check the Management Service module on the right section below the Management tab.

IIS - Management Service
IIS – Management Service

If the module does not appear, you can install the Management Tools from the Windows features.

6. The activation of the Web Management Service
The module need to be in a running state. You can activate the option “Enable Remote Connections” by double clicking the module, and make start.

IIS - Management Service 2
IIS – Management Service 2

7. The installation of the Msdeploy in the target machine
The MsDeploy need to be installed in the target machine. For this, you can download the relevant installment from the address below, and install it.

Within the process of installation, you need to activate the “IIS Deployment Handler” feature by choosing the “Custom” option.

MsDeploy
MsDeploy

Open the IIS to check whether the service has been installed successfully. Choose your server from the connections window on the left. Check the Management Service Delegation module which is on the right and below the Management tab.

IIS Management Service Delegation
IIS Management Service Delegation

Everything is ready. Right now we can prepare the pipeline in the Jenkins.


Open Jenkins, follow the way “New Item > Pipeline” and create “job”.

Jenkins - New Item
Jenkins – New Item

Paste the script below to the Pipeline section.

We are done. From now on you can make “Build Now”. Good luck…

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *