Jenkins Docker Image with Pre-Installed Plugins

VinothKumar P
3 min readJul 11, 2020

--

https://www.linkedin.com/in/pvinothkumar/

Jenkins® is an open source CI Tool. With Jenkins, organizations can ease the software development & deployment process by automating it. Jenkins manages and controls Continuous delivery processes throughout the entire lifecycle of the application, which including build, static code analysis, test, package, stage, deployment and much more.

You can set up Jenkins to work with any code changes in places like GitHub, Bitbucket or GitLab and automatically do a build a with tools like Maven and Gradle. You can integrate with container technology such as Docker and Kubernetes, initiate tests and then take actions like rolling back or rolling forward in production.

As we all know Jenkins has a lot of Tools- Plugins integrated along with. We definitely felt boring every time while installing and configuring about the list of plugins that we need to use or download.

Here is the way to use your upcoming Jenkins for any testing or production ready approach . We will get rid of this concern with Dockerized Jenkins Image again it is a custom one. Lets see how to get the one!

I have a custom Dockerfile for Jenkins setup along with preinstalled plugins while building the docker Image.

FROM jenkins/jenkins MAINTAINER   VinothKumar P <vinothkumar.P@Yahoo.com>ENV JENKINS_USER admin
ENV JENKINS_PASS admin

# Skip initial setup
ENV JAVA_OPTS -Djenkins.install.runSetupWizard=false


COPY plugins.txt /usr/share/jenkins/plugins.txt
RUN /usr/local/bin/install-plugins.sh < usr/share/jenkins/plugins.txt
USER root
RUN apt-get update -qq \
&& apt-get install docker-ce -y
RUN usermod -aG docker jenkins
RUN apt-get clean
USER jenkins

In the above docker file , Initial setup will be skipped as we have our custom plugins list on separate file and we have set username and password for logging in.

Since i need docker explicitly for my project i have built it along with , Remove the steps if required for clean Jenkins only image.

This image will be heavy as we started with base as plain Jenkins . If you want a light weighted image you can use below one with our favorite alpine base image.

FROM jenkins/jenkins:alpineMAINTAINER   VinothKumar P <vinothkumar.P@Yahoo.com>ENV JENKINS_USER admin
ENV JENKINS_PASS admin

# Skip initial setup
ENV JAVA_OPTS -Djenkins.install.runSetupWizard=false


COPY plugins.txt /usr/share/jenkins/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/plugins.txt
USER root
RUN apk add docker
RUN apk add py-pip

USER jenkins

As we mentioned in step 6 we need have a plugins.txt file in our dockerfile building directory. If you want you can specify the versions along with this and include necessary plugins too.

plugins.txt

ant
antisamy-markup-formatter
branch-api
cloudbees-folder
credentials
cvs
docker
durable-task
external-monitor-job
git-client
git-server
git
github-api
github-branch-source
github
javadoc
jquery-detached
junit
ldap
mailer
matrix-auth
matrix-project
maven-plugin
metrics
pam-auth
plain-credentials
scm-api
script-security
ssh-credentials
ssh-slaves
subversion
translation
variant
windows-slaves
workflow-aggregator
workflow-api
workflow-basic-steps
workflow-cps-global-lib
workflow-cps
workflow-durable-task-step
workflow-job
workflow-multibranch
workflow-scm-step
workflow-step-api
workflow-support
favorite
token-macro
pipeline-stage-step
blueocean
blueocean-autofavorite
gitlab-plugin

After building this dockerfile to a image we have our custom image ready to use it in a testing or Production ready environment.

#Jenkins #Docker #Container #Jenkins_Plugins

--

--

VinothKumar P
VinothKumar P

Written by VinothKumar P

Cloud DevOps Engineer 3 at Amadeus Labs| AWS/Azure Cloud ☁️ | DevSecOps | Docker | Kubernetes

Responses (2)