Integration of Docker,Github & Jenkins
Astha Goel
Salesforce Developer@Girikon Solutions| 2x Salesforce Certified | Salesforce | Sales Cloud | Apex | AI Enthusiast |KIET'23
1. Create container image that’s has Jenkins installed using dockerfile
2. When we launch this image, it should automatically starts Jenkins service in the container.
3. Create a job chain of job1, job2, job3 and job4 using build pipeline plugin in Jenkins
4. Job1 : Pull the Github repo automatically when some developers push repo to Github.
5. Job2 : 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 ).
6. Job3 : Test your app if it is working or not.
7. Job4 : if app is not working , then send email to developer with error messages.
8. Create One extra job job5 for monitor : If container where app is running. fails due to any reson then this job should automatically start the container again.
1.Create container image that’s has Jenkins installed using Dockerfile.
2.When we launch this image, it should automatically starts Jenkins service in the container.
4. Job1 : Pull the Github repo automatically when some developers push repo to Github.
See the uploaded Code by Developer.
Added this github URL so that data can be taken by this Git Repository.
Github hook trigger for GITScm polling is used so that when there will be changes on Repository,Github will trigger Jenkins using Public link provided to the Github Rpository using Ngrok.
Public Link(by ngrok) for Jenkins is added into the respective Github Repo by Webhook Concept.
5. Job2 : 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 ].
Here,there are 2 pages on the github repo.One of Php ,One of Html.So,Now respective pages will run into the containers having their interpreter installed.
Here,I used pre-created image,vima13/apache-webserver-php which php interpreter already installed; and own created image task:v1 having softwares required for HTML page.
Like;
Here,whenever any container will be launched ,web service will be automatically started as /usr/bin/httpd -DEFOREGROUND is used which is the program loads behind the scene on using systemctl start httpd.
But,here systemctl not work in the docker,so used this internal program.
6. Job3 : Test your app if it is working or not.
We know that,every web page returns the http status code.If code =200,page is working fine otherwise there r some issues.So,we are checking status code of our web pages(push by developer) to check our app working.
7. Job4 : if app is not working , then send email to developer with error messages.
If status not=200 ,we exit and mail sent to the developer.
Note: We need to doit also in Jenkins-->Manage Jenkins-->Configure System-->E-mail Notification,so that mail can be sent sucessfully.
8. 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.
3. Here's the build pipeline of Job1,Job2,Job3,Job4,Job5:
Here is my github repo link for the Reference.
https://github.com/asthagoel01/t2.git