image

Well, all of us know what Jenkins is. If you are new to Jenkins, it is one of the well known open source automation CI (Continuous Integration) tool that is extensively used to build, test and deploy software. Azure provide a support for Jenkins giving Azure Jenkins template available in azure marketplace, which will provision a Jenkins server hosted in Linux platform.

This post is also the continuation of my .NET Core migration strategy path. If you are planning to implement DevOps in azure having Jenkins as one of the implementation strategy, then I would recommend you to go through my initial post (link will be shortly added) which covers some details which you might like.

Anyway, lets go step by step on the installation process.

SSH key creation process using Putty

Putty is an SSH and telnet client which we use to remote access any virtual machine through remote shell process without directly RDP to the server.  However, in this post I will also try to show you how we can do RDP to a Linux (Ubuntu) machine.

Go ahead and download and install Putty from the following link.  Once Putty is installed, we will use PuTTYgen to generate a SSH key that we are going to use while configuring VM settings during Azure Jenkins installation process. In case you are wondering what exactly this SSH key is, it is an encrypted connection protocol that allows to do secure sign-ins over unsecured connections. It has 2 keys – Public (placed in Linux VM) and Private (that is used to make SSH connection). For more details, please visit this link.

Alright, search for PuTTYgen which should most probably be in this location “C:\Program Files\PuTTY\puttygen.exe” and open it. Click Generate, in order to generate a public/private key pair. Once the key is generated, you can provide a passphrase which add an extra level security for authentication purpose or you can leave it blank. I am creating a passphrase for me. BTW, the passphrase once created cannot be retrieved in case you don’t remember it or have lost it. Hence store it somewhere.

Save both the SSH Public Key and SSH Private Key. You need to provide the SSH public key content while configuring the basics of Jenkins installation.

 

image

You can also generate SSH key using Azure Cloud Shell. You can see the process in this post of Azure Team City installation.

 

Installation of Azure Jenkins

Search for Azure Jenkins in Azure Marketplace. Select the template to install Jenkins

image

image

Provide the Basic Configuration like server name, user name, resource group and location. For the Authentication Type, select SSH public key and provide the public key that you have stored or generated through Puttygen or Azure Cloud Shell

 

image

In the next Additional Screen, provide the required information like VM size, VM disk type, Subnets, Domain name and Jenkins LTS version which provide the release line information. You can get some details about Jenkins release line from this link

 

image

In the Integration Settings tab, select the Service Principal and Enable Cloud Agents.

Keep the Service Principal as Auto which means that the principal will be created by MSI (Managed Service Identity). Specify the default cloud template for agents in Enable Cloud Agents. I am selecting ACI (Azure Container Instance) since I will be using AKS. You can choose VM.

image

Finally the Summary section will provide the details for Jenkins installation.

image

You will find the option to download the template and parameters. I am going to download it as I would like to use Azure Automation to do the same task at later point. Check out the price for running Jenkins. Since I am using Jenkins under Ubuntu platform, I can avail the pricing details from the pricing list page

image

Once Jenkins is installed successfully, I can revisit the resource group where Jenkins has been installed to view the list of resources created.

image

I can directly access the Jenkins server using the domain name that I have created. However, I am going to SSH the server remotely using Putty.

image

Before that, let us browse the DNS to see if we are able to view the Jenkins page.

 

image

 

Access Jenkins Server remotely using Putty

Open Putty and in the Configuration screen, provide the DNS name in the Host Name field along with the Port number.

image

Upload the SSH Private key that you have generated in the Auth section.

image

And the click Open. You will be redirected to the Authentication screen where you need to provide the Username and the Passphrase. Following this, you will be connected to the VM.

image

 

image

We need to setup the tunnel forwarding to Jenkins using Putty, so that instead of using the DNS name, we would like to use http://localhost:8080 to access Jenkins server.

Open PuTTy and configure the tunnel based on the following screenshot.

image

After that open Command Prompt and type the command “putty.exe -ssh -L 8080:localhost:8080 netcoremigrationadmin@jenkins2018.southcentralus.cloudapp.azure.com” where netcoremigrationadmin is my username and jenkins.southcentralus.cloudapp.azure.com is my domain name.

image

Once that is done, you will be redirected to the window where you need to provide the Passphrase that you have created earlier. Once you are done, you can browse the Jenkins url http://localhost:8080.

image

In the PuTTY command prompt, type the following command  sudo cat /var/lib/jenkins/secrets/initialAdminPassword to get the initial password

image

Copy the password and put it in the initial screen of JenKins where you need to unlock it. Click Continue.

This will open the following window

image

Select Install suggested plugins which will install the plugins.

image

In next screen you need to setup the Admin user.

image

That’s it you are set with JenKins.

image

 

Remember that in order to SSH to JenKins using PuTTy, you need to always run the command putty.exe -ssh -L 8080:localhost:8080 netcoremigrationadmin@jenkins2018.southcentralus.cloudapp.azure.com in command prompt and then browse to JenKins using http://localhost:8080

 

Doing RDP to Jenkins Ubuntu system

There might be situations where you would like to RDP the Jenkins server in order to cross verify some settings or perform some operations like file check, directory check, etc. Now, since this is an Ubuntu system, you cannot RDP it directly. Even if you try to do RDP, you might encounter the below issue.

image_thumb36

Hence in order to perform RDP to the Jenkins server, we need to to install xfce4 which will make Xubuntu desktop environment available and then install xrdp which will enable Remote Desktop Protocol server in the Linux machine.

Install Azure CLI if you have not done so yet. After having Azure CLI installed, open Command Prompt in Administrative mode.

Type the command ssh {VM User Name}@{Jenkins DNS Name} . For me its going to be like this ssh netcoremigrationadmin@jenkins2018.southcentralus.cloudapp.azure.com.

Now we need to install xfce and xrdp. Type the following commands in sequential order-

  • sudo apt-get update
  • sudo apt-get install xfce4
  • sudo apt-get install xrdp
  • sudo service xrdp restart
  • sudo passwd {Admin user name}

It will ask for password so you can go ahead and give it.

Once everything goes well, lets try to RDP the Ubuntu machine.

image

image

Once you had been successfully authenticated, you will be able to get inside the Ubuntu system.

image

Hope this helps…

As part of .NET Core Migration Strategy, our next post deals with Azure Container Registry and Azure Kubernetes Services.

Leave a Reply