TASK 2 — DEVOPS

Sathvika Kolisetty
3 min readMay 17, 2020

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.

So we will start by creating a Dockerfile using centos: latest image pulled from docker hub.

FROM: the image to be used for container

RUN: commands to be executed while building the modified container

We will be installing wget for downloading the files from url, and before moving further we will set up the yum repository for Jenkins from URLs using wget command. Then we will first install java as it is a prerequisite for the smooth functioning of Jenkins. We will make a Jenkins entry in the sudoers file to give it root powers without the requirement for any password. We will also require Git installed to be used in Jenkins as a plugin. Python3 is installed for a mailing code that will be used later in a job.

To build the image we will use: **. is to be replaced with the path of Dockerfile.

docker build -t jenkin:latest .

On successful build, you will see a screen like this.

Now we will run our container.

docker run -it --privileged -p 9999:8080 -v /:/host jenkin:latest

— privileged has been used for special access to be used later while playing with dockers.

v: the mount seen here has been done for the same as well.

First job :

Now job 2

Now job 3

Job3 will be successfully built if the test fails so it can go to Job4 and mail to dev.

Now job 4

job 5

build pipeline:

--

--