Problem Statement:

1. Create a container image that’s has Jenkins installed using Dockerfile.

2. When we launch this image, it should automatically start the Jenkins service in the container.

3. Create a job chain of job1, job2, job3 and job4 using the build pipeline plugin in Jenkins.

4. Job1: Pull the GitHub repo automatically when some developers push the repo to GitHub.

5. Job2: By looking at the code or program file, Jenkins should automatically start the respective language interpreter.

6. Job3: Install image container to deploy code ( eg. If code is of PHP, then Jenkins should start the container that has PHP already installed ).

7. Job4: Test your app if it is working or not.

7. Job5: If the app is not working, then send an email to the developer with error messages.

Solution: Requirements: Jenkins in base OS (Redhat,CentOS) with plugins like Github, Build Pipeline, Downstream-ext.

Github Link:

So i created a Dockerfile to install jenkins using base centos image. You can get from my repo

Use this command to create image of Dockerfile

docker build -t jenkins:new .

Step 2: Now you can run container using that image

docker run -dit --name jenkins -p 8085:8080 jenkins:new  

It will start jenkins automatically on base OS IP with port no 8085. For login inside jenkins give username admin and password is inside container

docker exec -it jenkins bashcat /root/.jenkins/secrets/initialAdminPassword

Then by using password log in inside jenkins and install Github and Build Pipeline Plugin

Step 3: Job1: Provide github repo link and type same commands in execute shell. I have used Poll SCM trigger in my job1. It will basically copy all your files from repo to your container.

JOB2: It checks the type of file which are present in repo like html or php. I have used html file.

JOB3: It is in Base OS jenkins which i have triggered using remote script option. Based on type of file it launches container capable of deploying them like in my case httpd container for html files.

JOB4: It will test your app if it is working or not and if not then it will trigger JOB5

JOB5: It will send an e-mail to developer if JOB4 fails.

Build Pipeline View of Docker jenkins
Build Pipeline View of Base Os Jenkins

The mail would look like this

Note: Please use your credentials in

For sending mail you would have to turn on Less Secure Options

Github Link: