Automation using pipeline in Jenkins Image integrating with Docker and GitHub

Automation using pipeline in Jenkins Image integrating with Docker and GitHub

In this task I will be developing a CI/CD pipeline which downloads the code form GitHub and deploys on respective Docker Image

Problem Statement:

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

4. Job1 : Pull the Github repo automatically when some developers push repo to Github.

5. Job2 : By looking at the code or program file, Jenkins should automatically start the respective language interpreter installed image container to deploy code ( eg. If code is of PHP, then Jenkins should start the container that has PHP already installed ).

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

7. 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. fails due to any reson then this job should automatically start the container again.

To solve this task I have developed my own custom docker image called "syedfaheem/jenkins:v4"

I have use the below Dockerfile for creating it

No alt text provided for this image


We can download the by using the below command

docker pull syedfaheem/jenkins:v4

then start the container

docker run -dit  -v /root/task2:/root/mlops-task2 -p 80:14356 --name dev syedfaheem/jenkins:v3

Go to IP:14356 [Here IP is the IPAddress of the Host VM]

No alt text provided for this image

then go to /root/.jenkins/secrets/initialAdminPassword

docker exec -it dev bash

cat /root/.jenkins/secrets/initialAdminPassword
No alt text provided for this image

In the above pic the highlighted is the password which is used to login

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

Wait for a while till the plugins gets installed

Now I will be generating the ssh key and send it to the host VM as it will be required in the task

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

So we have successfully sent the generated ssh key and sentit to the host VM

This will us to do ssh from the container to the host VM without using password

For Ex:

No alt text provided for this image

So lets start our Jobs in jenkins

JOB1

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

This will automatically get triggered when ever there is a change in the Git Repo and it will download the code in the folder specified

JOB2

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

This job will remote login into host VM and deploy the code in the required container. Here I have taken only one file (index.html)but soon will update it

So for html I will deploy it in httpd container

JOB3

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

The main purpose of the job is to check whether the deployment is done correctly or not. If it is not correctly done then it will notify the email recipient. Basically it does testing

JOB4

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

The main purpose of this Job is to monitor whether the container is running or not

Build Pipeline View

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

Hence we have successfully deployed the webpage

Feel free to ask any queries

Name: Syed Faheemuddin

university of Hyderabad

LinuxWOrld

email Id : [email protected]




要查看或添加评论,请登录

Syed Faheemuddin的更多文章

  • AWS CLI TASK2

    AWS CLI TASK2

    In this article I will integrate various services of AWS : EC2, EBS, S3 and Cloud Front I will launch a webserver using…

  • Transfer Learning using MobileNet

    Transfer Learning using MobileNet

    What is Transfer Learning? Transfer learning is the reuse of a pre-trained model on a new problem. It's currently very…

  • Getting Started with AWS CLI

    Getting Started with AWS CLI

    Have you ever imagined if you had to run 100s of instances at a time to solve a particular use-case. We all know much…

  • Infrastructure development With Ansible and Docker

    Infrastructure development With Ansible and Docker

    Nowadays Automation is everywhere Ansible and Docker are the most important tools in DevOPs and they are playing a…

    6 条评论
  • Jenkins Testing and Production Environment with Automation

    Jenkins Testing and Production Environment with Automation

    TASK 1 --> MLOPS and DevOps Assembly Lines In this task I will explain a SMARTER and AGILE way to manage testing and…

  • Integrating ML with DevOps

    Integrating ML with DevOps

    In this article I will explain my first MLOPS project which successfully completed under Vimal Daga Sir. In this…

社区洞察

其他会员也浏览了