BUILDING PIPELINE AND LAUNCHING JENKINS IN CONTAINER
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.
- REDHAT ENTERPRISE LINUX 8
- 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.
STEP-2 Come out of the folder and write the following code as shown below. To build the Docker within the Operating System.
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.
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.
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.
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.
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.
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.
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.
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.
I have made here the Pipeline which is shown below. It will be the full fledged output of the setup we created.
Thanks a lot !!