Continuous Integration And Continuous Deployment Using Jenkins In Azure Virtual Machine.


How to Configure Continuous Integration And Continuous Deployment Using Jenkins In Azure Virtual Machine.

Continuous Integration Generally refers to the practice of automate the process of the integrations of code changes from the multiple contributors into a single project.

Continuous Deployment is a methodology which ensures that the code primarily pushed into the production servers whenever there is a new commit occur in the code database or into the source code management system.

This blog generally is based on the following case study:-


we can divide the current workflow into few steps:-

Step 1:- Configuring the Azure Virtual Machine.

1. create a resource group.


2. create a azure virtual machine inside the created resource group.





3. To install the jenkins dashboard into your server you need to add a following inbound rule.



4. Then ssh into your virtual machine in order to carry out the other steps.


Step 2:- Installing Jenkins

Prerequisite :- To install Jenkins to your system you need to Java installed into your system.

1. To add the Jenkins repository, You have to add the following key to your system.

curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee \
    /usr/share/keyrings/jenkins-keyring.asc > /dev/null
2. Then run the following command to add the Jenkins apt repository entry.

 echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
 https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
 /etc/apt/sources.list.d/jenkins.list > /dev/null
3. Run the following commands to java development kit and Jenkins into your system.

 sudo apt-get update
 sudo apt-get install fontconfig openjdk-11-jre
 sudo apt-get install jenkins
Then Run the following the command to start the Jenkins and the status of Jenkins.
systemctl start jenkins | systemctl status jenkins.

if in case any error occurs while installing Jenkins into your system, you can checkout the official documentation of Jenkins.




Install git and apache2 into your virtual system.

1. Run the following command to install git.
 
apt-get install git (ubuntu server)

2. Run the following command to install apache2.

apt-get install apache2 (ubuntu server)



Step 4:- Configure Jenkins and set up job in Jenkins.

1.  After Installing Jenkins, you can access the Jenkins dashboard by sending the request to <Your Server Public ip>:8080.


To get the Initial Admin Password use cat command.

cat /var/lib/jenkins/secrets/initialAdminPassword




Steps To create job in Jenkins.

click on create a job.


Here we have used the GitHub as the Source Code Management but there are other alternatives such as (big bucket, Azure repos etc).


In order to integrate the GitHub and Jenkins you need to create a webhook as follows:-




In order to Configure the Job in Jenkins follow this steps:-


here I am using a public repository therefore we don't need add the GitHub credentials but in case of private repo you need to add your GitHub account credentials in Jenkins while configuring the job. 






Then After configuring the job click save and apply. Before clicking build now in Jenkins run the following command in your server kernel.

vi /etc/sudoers 

and Add the following line

Jenkins ALL=NOPASSWD:ALL 

(or else the Jenkins build will be a failure and your website will not be deployed in the server).


Then to start the processing of your job you need to click on build now button.






Then Finally your website will live in http://<your server ip>


Thank you.














     

Sibasish

I am a student pursuing Computer Science and Engineering at Silicon Institute of Technology. I am always eager to explore the world of computer Science and software development . Main areas of interest include Web-development, Machine Learning, and Cloud Computing.

Post a Comment

Previous Post Next Post