Automated Testing & Production Environment | Jenkins | Docker
Khushi Thareja
Aspiring DevOps-Cloud Architect | RHCE v8 | 4x Redhat Certified | 3x Microsoft Certified
In this task the most interesting thing to do was launching a docker container inside another docker container. We had to create a container image that has Jenkins installed using Dockerfile.
After we build the image and the run the following command to launch a conatainer ,it launches a conatiner on which the jenkins is running on the specified port ie. 8082
After this we need to create a job chain ie. job 1, job 2 , job 3 using build pipeline in Jenkins. The task for the first job is to pull the file from the GitHub repository automatically when some developer pushes the file to the GitHub . For this purpose we used the post-commit file which automatically triggers Jenkins whenever a file is pushed.
The first job works on remote triggers and copies the file recieved from the GitHub repositiory to the specified project folder.
As soon as the first job is built stably , it triggers our next job that is our job 2 whose task is to launch the container from the respective image which has the required software installed. For this purpose we have constructed the python code which triggers the dockerfile and buils the image .
And after the image is build ,our job2 launches a new container with the respective interpreter installed and running.
A new job is created which tests whether the application is running successfully or not and if the application is not running it sends an email to the developer regarding the issue. For this we have used the concept of error codes by delibeartely sending an error code so that when the job fails when the container is not running it triggers the post build action of sending and email and the mail is sent to the developer successfully.
The Email plugin is setup in the following manner
Job 4 just monitors the containers and if it is not present then launches it again.
This is the build pipeline veiw
Do leave your valuable feedbacks . For any queries or correction feel free to contact