AWS, Cloud Computing

4 Mins Read

A Tutorial on Building a Deployment Pipeline with Custom Jenkins Image

Problem Statement
Important steps used
Github clone
GitHub Configuration
Deployment configuration
Test Job Configuration

Problem Statement

Creating a Dockerfile to create Jenkins container image and then automate provisioning the environment to deploy the webpages with the help of Jenkins.


Docker must be installed and in running state, CENTOS system is employed in this tutorial. (If you are using other operating systems then use their respective package and service manager.)

We have created a Dockerfile using a base image as centos 7 and then created a Jenkins container image.

Important steps used

Jenkins requires java to be installed in the backend,
2. Wget is installed to download Jenkins official repository from the web,
3. Then the gpg-key is added for the yum repo to get authorized,
4. We install Jenkins as the yum repo is configured with proper gpg-key,
5. To start Jenkins service we have to install service utility,
6. For the connection to Jenkins server, it must be exposed on 8080 port,
7. Finally, we have a script that starts Jenkins service (with the help of the service utility) and puts the container in sleep mode so that it will not get stopped.

Docker file to create Jenkins Image

Github clone

We can create the docker file by using the following command:
docker build -t image_name: version workspace_name
where workspace_name = absolute path where the Dockerfile is present.

We will now launch the Jenkins server by using the above image.

Now using this image, we have launched the Jenkins container and created five jobs

  1. Github_clone
  2. Deploy
  3. Test
  4. Notify
  5. Monitor

This job will clone from the GitHub repository on the Jenkins server and hence this code will be used for the deployment of the website.

Image-1: It depicts the repo URL from where the code will be fetched for the deployment.


Image-2:  It depicts the <username> @<ip> (to ssh plugin) of the server on which the given commands are to be executed (ignore the warnings if any). The command is to copy the github_clone repo from the container to the document root of the web server (so that it will be hosted).


GitHub Configuration


We run a container and mount the repo in the document root inside the container and then this job will deploy the code into the container by using docker in the Redhat system. ssh plugin is used to deploy it on a remote host because Jenkins is running on the container, therefore, we require to build this job on a remote host.


Deployment configuration

If the code that is used is written in some other language then we can install its respective interpreter using the yum install <interpretor package name> (e.g if PHP is used then install PHP-CLI).


This job will check the status code of the web pages given by the browser and if some bugs show up then a notification will be sent to the developer with the error message embedded in it.


Test Job Configuration

Using the email plugin the email notification is configured, which can be configured as shown:



This job is to monitor the deployment job, So, if the container crashes or fails it will automatically create a new container for the use.


About CloudThat:

CloudThat provides end-to-end support with all the AWS services. As a pioneer in the Cloud Computing consulting realm, we are  AWS (Amazon Web Services) Advanced Consulting Partner, and Training partner. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Read more about CloudThat’s Consulting and Expert Advisory.

Voiced by Amazon Polly




    Click to Comment