blog bg

August 19, 2024

Streamlining Your CI/CD Pipeline: Installing Jenkins on an Azure VM

Share what you learn in this blog to prepare for your interview, create your forever-free profile now, and explore how to monetize your valuable knowledge.

In the realm of DevOps, Continuous Integration/Continuous Deployment (CI/CD) is the cornerstone for delivering software efficiently and reliably. Jenkins, an open-source automation server, has long been a favorite tool among developers and DevOps engineers for orchestrating CI/CD pipelines. In this blog post, we will walk through the process of installing Jenkins on an Azure Virtual Machine (VM), providing you with a robust platform to automate your software delivery pipeline.

 

Why Jenkins on Azure VM?

Azure VMs offer a scalable and flexible infrastructure for hosting applications and services. By deploying Jenkins on an Azure VM, you gain access to Microsoft's powerful cloud platform while leveraging the capabilities of Jenkins to automate your CI/CD workflows. This setup allows you to manage your build, test, and deployment processes seamlessly in a cloud environment.

 

Prerequisites

Before diving into the installation process, ensure you have the following:

  1. An active Azure subscription.
  2. Access to the Azure portal.
  3. Basic knowledge of Linux commands (if deploying a Linux VM).
  4. Familiarity with Jenkins and CI/CD concepts.

 

Step 1: Provisioning an Azure Virtual Machine

  1. Log in to the Azure portal.
  2. Navigate to the "Virtual machines" section.
  3. Click on "Add" to create a new VM.
  4. Choose the desired operating system (Linux or Windows), VM size, authentication method, and networking options.
  5. Follow the on-screen instructions to complete the VM creation process.

 

Step 2: Connecting to the Azure VM

Once the VM is provisioned, connect to it using SSH (for Linux) or Remote Desktop (for Windows). You can obtain the necessary connection details from the Azure portal.

 

Step 3: Installing Java

Jenkins is built on Java, so ensure that Java Development Kit (JDK) is installed on your Azure VM. You can install OpenJDK or Oracle JDK based on your preference and requirements.

For Ubuntu/Debian:

sudo apt update
sudo apt install default-jdk -y

 

For CentOS/RHEL:

sudo yum install java-1.8.0-openjdk-devel -y

 

Step 4: Adding Jenkins Repository and Installing Jenkins

Add the Jenkins repository key to your system:

wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -

 

Append the Jenkins repository to the system sources list:

sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

 

Update the package index and install Jenkins:

sudo apt update
sudo apt install jenkins -y

 

Step 5: Start Jenkins Service

Once Jenkins is installed, start the Jenkins service and enable it to start on boot:

sudo systemctl start jenkins
sudo systemctl enable jenkins

 

Step 6: Accessing Jenkins Dashboard

Jenkins runs on port 8080 by default. Open your web browser and navigate to:

http://your-vm-public-ip:8080

 

Follow the on-screen instructions to complete the Jenkins setup wizard. You will need to retrieve the initial administrator password from the VM:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

 

Step 7: Configuring Jenkins

Once logged in, you can start configuring Jenkins according to your requirements. Install necessary plugins, set up build jobs, integrate with version control systems, and define your CI/CD pipeline.

 

Conclusion

By installing Jenkins on an Azure VM, you lay the foundation for building robust CI/CD pipelines in the cloud. Azure's scalability and Jenkins' automation capabilities combine to provide a powerful platform for accelerating software delivery while maintaining quality and reliability. With this setup, you can streamline your development workflows and focus on delivering value to your customers efficiently.

 

260 views

Please Login to create a Question