THE INTEGRATION OF GITHUB,DOCKER, AND JENKINS

The integration of Docker, Jenkins, and Github


The Project Of DevOps Training Under Linux World,India

Project Description:

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

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

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

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

5. Job2: By looking at the code or program file, Jenkins should automatically start the respective language interpreter install 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 the app is not working, then send an email to the developer with error messages.

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

SOLUTION:==>

I start by creating a Dockerfile using centos: latest image pulled from docker hub.

No alt text provided for this image

Here installing...

1..sudo for root powers ,

2. wget for downloading the files from url,

3. installing net-tools for viewing IP address( specially for ifconfig)

4.set the yum repository for Jenkins from URLs using wget command.

5. install java for Jenkins.

5. created Jenkins entry in the sudoers file to give it root powers without need of any password.

6. installed git for Jenkins .

7. installed Python3 for mailing via python code.

After creating image by command "docker build -t name:version"

We have to run the container from this image "docker run -itd -p 1234:8080 --name hw2 --privileged name:version"

Here we have to give admin password shown in terminal (shown below)

No alt text provided for this image


No alt text provided for this image

Here we Successfully ran the image and now download all suggested plugin first and then we can use the jenkins smoothly...

No alt text provided for this image

Now we will do the jobs as asked in give problem...

Job 1.

The first job is Pull the GitHub repo automatically,for this we have to do some steps as shown below..

Step 1. Click on the "Github project" in first general section and enter your github repository url in project url section...

No alt text provided for this image

Step 2. Click on the "Git" in Source Code Management section and enter github url again in repository url ...

No alt text provided for this image

Step 3. Select "Github hook triggeer for GITScm polling" and in Build Environment section Select "Add Timestamps to The Console Output "

No alt text provided for this image

Step 4.In "Build" Section select the "Execute Shell" for writing code , in tjhis code we create a repo directoryif it is available then first remove it create a new web-repo directory it's done for Job 1... Apply and save the job

No alt text provided for this image

Job 2.

Job 2 is simpler then previous one,From here we are going to start a chain of job. for this

Step 1. we select "Build After other project are built" in "Build Triggers" section

No alt text provided for this image

Step 2.We have to write a code which work After Job 1 built successfully it will deploy a container(httpd container named as "ak_dep") on the host system... it's done. apply and save

No alt text provided for this image

Job 3.

Step 1. For making chain select "Build after ....." as we did in Job 2

No alt text provided for this image

Step 2. For testing our application we have created this job. after test fails it will got to Job 4 for mail to developer email address.

No alt text provided for this image

Job 4.

Step 1. as in JOb 2 and Job 3 we have to create chain by selecting "build after projects are built" ..

No alt text provided for this image

Step 2. We only have to write here "python3 mail.py" because we have created a python program file along with the Dockerfile.. This job is for sending the mail to developer if tsting of our application fails..

No alt text provided for this image

Job 5.

In configuration of Job 5 we only have to do 2 things one to create job/task chain and select the "Build Periodically" to schedule the interval here we have given five stars this means that we need to run this job every minute ..

No alt text provided for this image

We have done the creation of job successfully,

All created jobs are successfully built (The blue ball shows that it is successfully built )...

No alt text provided for this image

Now we have to see the results in Build Pipeline View...

No alt text provided for this image

We have done the Task succesfully ... Thanks to vimal sir...

Comments

Popular posts from this blog

Name.com with Github in 2 steps

Integration of Github, Jenkins, and Docker