Task 2
This task is a complete end to end automation using Jenkins, docker on the base OS red hat 8. This task consists the following sub tasks.
Job1:- Create container image that’s has Jenkins installed using docker file and when we launch this image, it should automatically starts Jenkins service in the container.
This dockerfile contains one expect language along with the jenkins software.
Using expect language I created Keygen it will automatically create a public key which is used for authenticate while ssh, Copyid it will copy the public key to the base OS and for which it used remote host name and password for the base OS . For taking remote host name and password the environmental variable is used and to run this container it must be initialized.
Job2:- Create a job chain of job1, job2, job3 and job4 using build pipeline plugin in Jenkins.
Job3:- Create a job1 which pulls the Github repo automatically when some developers push repo to Github.
This job pulls the github repo from the developer's repo and after that it will create the production directory inside the jenkin's container and move the files inside that folder.
Job4:- Create a job2 which will 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 ).
Job4 do this by first store each kind of files(for simplicity I took 2 kind of file i.e php and html) in arrays.
Then for each kind of files stored in two arrays it will transfer the each file in the base OS i.e red hat via scp protocol and then start the container that contain respective language interpreter(for HTML I have used httpd image and for php image which has PHP and Apache server pre installed).
Job5:- Test your app if it is working or not.
This job uses exit code of curl command to determine weather the app is running or not.
Job6:- if app is not working , then send email to developer with error messages.
Job7:- Create One extra job job5 for monitor : If container where app is running. fails due to any reason then this job should automatically start the container again.