Deploying Applications with Jenkins Container

MLOps Task 2

Task Description :

2. When we launch this image, Jenkins service automatically starts in the container.

3. Create a job chain of Job 1, Job 2, Job 3 and Job 4 using build pipeline plugin in Jenkins.

4. Job1 : Pull the Github repository automatically when developers push the Code to Github.

5. Job2 : By looking at the code or program file, Jenkins should automatically start the respective language interpreter installed image container to deploy code ( eg. If code is of PHP, then Jenkins 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 an extra Job (Job 5) for monitoring basis : If container where app is running fails due to any reason, then this job should automatically start the container again.

Creating the Dockerfile in RHEL_8

After creating the Dockerfile, type the following code :

FROM centos:latest
RUN yum install sudo -y
RUN yum install wget -y
RUN yum install curl -y
RUN yum install git -y
RUN yum install net-tools -y
RUN yum install ncurses -y
RUN sudo wget -O /etc/yum.repos.d/jenkins.repo
RUN sudo rpm --import
RUN yum install java -y
RUN yum install initscripts -y
RUN yum install jenkins -y
RUN echo "jenkins ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
CMD service jenkins start

Save the Dockerfile and start the build process :

Now launch the Jenkins using the port 8080, and enter the jenkins .

Install the github and the build pipeline plugin to make the github work inside the jenkins and make the jenkins environment ready for the work.

After installing the plugin , now we move on to the JOBS.


JOB2 Configuration:

Here we have compatibility for python, html & php. If you want some more language to be handled then you can add it. One more thing here we need to take care of is we need to make containers for these language interpreter also. This I will shown in the later part of this article.


One more thing before running all the jobs you have to run this command python3 -m smtpd -c DebuggingServer -n localhost:1025 to start the smtp server to send mail automatically. One more thing create a mail ID for jenkins and make it’s security low i.e Go to manage account after login -> Security -> Less Secure app access -> on Here if the application is working fine it will send mail to my gmail account if failed as Error hosting website.

import smtplib, ssl

port =587
smtp_server = “”
sender_email = “
reciever_email =”
password = “<password >”
message=” “ “\
Subject: Error hosting website
JOB2 not completed properly “ “ “
context = ssl.create_default_context()
with smtplib.SMTP(smtp_server , port) as server:
server.sendmail(sender_email , reciever_email ,message)


Finally the build pipeline for the task