DevOps Automation done with Jenkins, GitHub and Docker container
Jenkins GitHub Docker

DevOps Automation done with Jenkins, GitHub and Docker container

GitHub offers the distributed version control and source code management (SCM) functionality of Git, plus its own features. It provides access control and several collaboration features such as bug tracking, feature requests, task management for every project.

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.

Docker is a set of platform as a service products 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.

This is an automation task where I have used GitHub, Jenkins and Docker platform to do continuous integration by uploading the project codes to GitHub and continuous deployment by fetching and deploying the code on the respective container by checking the type of code.

Enough Introduction Done!!!

start


These are the Steps that I have followed to do this automation task.

1. Create container image that’s has Jenkins installed using Docker file.

No alt text provided for this image

This is Dockerfile for creating the Docker image

No alt text provided for this image

Building of "jenkins:v1" docker image

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

No alt text provided for this image
docker run --privileged=true  -v /var/run/docker.sock:/var/run/docker.sock -v /gitclone:/gitclone -it -P --name jenkinstest jenkins:v1

Try this code to test on your device

3. Create a job chain of job1, job2, job3 and job4 using build pipeline plugin in Jenkins

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

These are the Jenkins job that we must created for build pipelines

Setup for uploading the code to the GitHub repository using Git bash:

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

4. Job1 : Pull the GitHub repository automatically when some developers push repository to GitHub.

No alt text provided for this image


No alt text provided for this image


No alt text provided for this image

This job first pull the git repo and then copy to the given location here it put it in "/gitclone/"

No alt text provided for this image

Output of Job1 when git repository is successfully fetched

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 ).

No alt text provided for this image

This task is triggered when Job1 is done

No alt text provided for this image

This code will first check the file type and then launch container accordingly

No alt text provided for this image

Output of Job2 when appropriate container according to the code is successfully launched.

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

No alt text provided for this image

This task is triggered when Job2 is done

No alt text provided for this image

This code is meant to test whether container is running or not

No alt text provided for this image

Output of Job3 when container test done successfully.

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

No alt text provided for this image

This task is triggered when Job3 is done

No alt text provided for this image

This post build action for sending mail to developer if build is unstable

No alt text provided for this image

Output of Job5 when container test done successfully and email send if some error occur.

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

No alt text provided for this image

This task is triggered when Job4 is done

No alt text provided for this image

This post build action if any error happens

No alt text provided for this image

Output of Job5

Setting up the email notification

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

Thanks for reading this article!!!!

For Dockerfile codes visit to my GitHub profile link below:

For Docker image visit to my Docker Hub profile link below:

This task is very special for me because it take so much time to complete and gives me good knowledge with this task I have learn how to integrate different technology which is the soul of automation.

I am highly greatful to my mentor 'A great person with lots and lots of knowledge' . The Great Engineer and Great Teacher Mr Vimal Daga Sir!!!

Thank you so much Sir for giving your precious time and also Thanks to LinuxWorld





To view or add a comment, sign in

More articles by Manish Verma

Others also viewed

Explore content categories