At whatever point we need to launch the container to test our code, we need to do this procedure manually in light of the fact that our Jenkins program doesn't think about the programming language in which the code is composed so in the event that our code is written in "PHP" at that point the container ought to have all the prerequisites introduced to run a "PHP" code.
To overcome this disadvantage, we use Jenkins Job that recognizes the code ("HTML" or "PHP") and launches the container as needs are for trying. On the off chance that the site isn't working appropriately, at that point Jenkins sends the administrator message container the log document of the bombed activity.
Note- We are using Job Name here As when we are working in Jenkins all the tasks are converted into jobs.
Task Description :
1. Make a container image that has Jenkins introduced utilizing Dockerfile.
2. At the point when we launch this image, Jenkins' administration naturally starts in the container.
3. Make a job chain of Job 1, Job 2, Job 3, and Job 4 utilizing the build pipeline module in Jen
4. Job1: Pull the Github vault automatically when developers push the code to Github.
5. Job2: By taking at the code or program record, Jenkins should automatically begin the individual language interpreter introduced image container to deploy code ( eg. In the event that code is of PHP, at that point Jenkins starts the compartment that has PHP as of now introduced ).
6. Job3: Test your application on the off chance that it is working or not.
7. Job4: in the event that the application isn't working, at that point send an email to the engineer with error messages.
8. Make an additional (Job 5) for monitoring premise: If the container where the application is running fails because of any explanation, at that point this activity job should automatically start the container again.
Creating the Dockerfile in RHEL_8
Step -1 Create a directory in RHEL_8 VM :
Step -2 After creating the Dockerfile, type the following code
Step -3 Staring Of Jenkins
Step -4 Save the Dockerfile and start the build process :
Step -5 Creating Multiple Jobs in Jenkins :
Pulling the code repository with Jenkins :
Step -6 JOB-2 :
In this Job, we will first have to check the type of programming language that the code is using and on the basis of the code, we will create and run a container.
Step -7 JOB-3 :
Creating a testing environment and checking if our code is working or not
Step -8 JOB-4 :
The main job is to check if the code is working or not and if the code is not working, it will send an E-mail to Jenkins admin attaching the build logfile if the Job fails in Jenkins.
Step -9 JOB-5 :
This last Job monitors our containers, if due to any reason our container stops or terminates then this job will launch our container again after the failure.
Step-10 At last, after performing multiple jobs in Jenkins, we can visualize our jobs with the help of Jenkins build pipeline plugin.
After Jobs are performed, the output of the working website and the pipeline plugin output looks like this
The task of automating the code deployment is successfully done in Jenkins