BUILDING PIPELINE AND LAUNCHING JENKINS IN CONTAINER

Rishabh Jain
5 min readSep 3, 2020

--

Hey! folks here comes a new blog on an automated system which will launch Jenkins in the container and after launching it we are going to build a pipeline for it. It is a very awesome practical as we are going to launch one OS in another OS and in just 2–3 seconds and then will be working in it.

PREREQUISITES :

  1. REDHAT ENTERPRISE LINUX 8
  2. DOCKER INSTALLED

So, let’s begin with it.

STEP-1 In RHEL8 (REDHAT ENTEPRISE LINUX 8) make a folder in it and create a Notepad File with the name Dockerfile and write the following code in it shown below.

MAKING FOLDER
CREATING FILE IN FOLDER
JENKINS CODE

STEP-2 Come out of the folder and write the following code as shown below. To build the Docker within the Operating System.

BUILDING DOCKER

You will be viewing the following output as shown below.

STEP-3 After it has done run the following command to run your Docker and to give access to it to connect to the Public World as shown here.

After the command is run you will see the following output to be here as shown below.

A Password will be generated as highlighted below.

PASSWORD FOR JENKINS

You can check it by writing the following command

docker ps as shown below.

STEP- 4 Now use the command docker inspect <docker id> as shown above.

STEP-5 Copy the IP Address and paste it in the browser of your Operating System.You will be landed to the page where you will see Jenkins page just copy the password highlighted in above picture and paste it their and you will be landed to the Dashboard of Jenkins.

After setting up the Jenkins let us now move to make the Jobs of the setup in Jenkins.

JENKINS STARTING

#JOB-1

In Job 1 Jenkins will pull the file from the github and after that Jenkins will copy the file to the web server folder as shown below.

GITHUB REPOSITORY
COPIED FILE TO FOLDER

We will also be setting up the Poll SCM option which will automatically notify if there will be any change in the code in GitHub and we will be setting up as

  • * * * * as it means that Jenkins will go to the GitHub for every second and check for the change in the code.
POLL SCM IS SET

#JOB-2

We are going to write the code that Jenkins will itself decide that if it is HTML file it will be launched in one docker and if PHP file the another docker will be launched as shown below. We will also be connecting the jobs in a synchronous manner.

JOBS CONNECTION

#Job-3

Now we will write the code that whether it is successfully launched or not. If launched it will show the status =200 or if any other status popped it will not execute the further process.

We will also be connecting the jobs in a synchronous manner as shown below.

JOBS CONNECTED
CODE FOR CHECKING STATUS

#Job-4

Now if the status is failed Jenkins will itself send a mail to the entered mail and will notify the developer that the code is failed to get the desired output as shown below.

In this job the above job-3 will also be going to connect as shown below.

JOBS CONNECTED
EMAIL SENDING IF CODE FAILED

After all the Jobs created , coded and connected among them synchronously. You can go and build the Pipeline to view and analyse the working of the jobs.

After all the Jobs are made you can view it on the Dashboard as shown below.

JOBS ON JENKINS DASHBOARD

I have made here the Pipeline which is shown below. It will be the full fledged output of the setup we created.

PIPELINE BUILDED IN JENKINS

Thanks a lot !!

--

--

Rishabh Jain
Rishabh Jain

Written by Rishabh Jain

I am a tech enthusiast, researcher and an integration seeker. I love to explore and learn about the right technology and right concepts from its foundation.

No responses yet