DEVOPS AUTOMATION USING JENKINS AND DOCKER

DEVOPS AUTOMATION USING JENKINS AND DOCKER


MLOPS & DEVOPS Task - 2


Technologies we have use here in this Task are:

1) Jenkins

2) Docker


Jenkins

Jenkins is a free and open source automation server. It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery. It is a server-based system that runs in servlet containers such as Apache Tomcat.

No alt text provided for this image
Docker

Docker is a set of platform as a service product that uses OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels

No alt text provided for this image

---------------------------------------------------------------------------------------------------------------

Objective of Task:

1) Create container image that’s has Jenkins installed using Dockerfile

2) When we launch this image, it should Automatically starts Jenkins service in the container.

3) Create a job chain of job1, job2, job3 and job4 using build Pipeline plugin in Jenkins :

----- Job1 : Pull the Github repository automatically when some developers push repository to Github.

------ Job2 : By looking at the code or program file, Jenkins should automatically start the respective language interpreter install Image container to deploy code.

------ Job3 : Test your app if it is working or not.

----- Job4 : if app is not working , then send email to developer with error messages.

8) Create One extra job job5 for monitor : If container where app is running. Any fail due to any reason then this job should automatically start the container again.

---------------------------------------------------------------------------------------------------------------

Procedure to Complete the Jobs:

Step 1: First we have to create a Dockerfile, for which i am using CentOS. I have installed Java in this OS because Jenkins runs over Java. Now, To give access to Jenkins for running the commands we have to do write following :

No alt text provided for this image

Now we have to Run the Dockerfile, for that we have to type :

docker build -t jenkinos:1.0 

---------------------------------------------------------------------------------------------------------------

Step 2 : Now we will Launch our Jenkins for Automation of our Tasks. In Jenkins we will Create Pipeline of 5 Jobs which will automate the launching of Docker file. Along with it we also Create a Github Repository where we will keep our Code, which can be automatically taken by our Jobs to Launch the Docker Container.


No alt text provided for this image
No alt text provided for this image

---------------------------------------------------------------------------------------------------------------

Step 3 : Job - 1

In this very first we will automate automatic download of the code from GitHub Repository as soon as developer commits any changes. After Cpying the Code it is pasted into Mlops Task 2 folder.

No alt text provided for this image
No alt text provided for this image

---------------------------------------------------------------------------------------------------------------

Step 4 : Job - 2

Objective of Job 2 is to look at the code or program file, Jenkins should automatically start the respective language interpreter install Image container to deploy code.

Job2 in Jenkins will Automatically start Building once Job one is Finished Succesfully.

No alt text provided for this image
No alt text provided for this image

---------------------------------------------------------------------------------------------------------------

Step 5 : Job - 3

Objective of Job 3 is to Test your app if it is working or not. It will be triggered after stable build of Job2.

No alt text provided for this image

The following code will check weather it is running successfully or not/?

No alt text provided for this image

---------------------------------------------------------------------------------------------------------------

Step 6 : Job - 4

Objective of task 4 is to if app is not working , then send email to developer with error messages.


No alt text provided for this image

---------------------------------------------------------------------------------------------------------------

Step 7 : Job - 5

Objective of Job 5 is to If container where app is running. Any fail due to any reason then this job should automatically start the container again.

No alt text provided for this image
No alt text provided for this image

We have Successfully Completed the Task -2 by Integrating Jenkins, Docker.

Link to Github:


To view or add a comment, sign in

More articles by Naman Jain

Explore content categories