Wednesday, April 25, 2018

Docker with Jenkins Plugins

At times you might want to add have a version of Jenkins that automatically has a predefined set of plugins installed .

You might want to find an existing jenkins with all the installed plugins assume the url is http://myjenkinshostname/jenkins to get the list of plugins you might need.

Navigate to http://myjenkinshostname/jenkins/script  there you want to past the following codes and execute :

def plugins = jenkins.model.Jenkins.instance.getPluginManager().getPlugins() plugins.each {println "${it.getShortName()}: ${it.getVersion()}"}

There are other ways to also get the  list of plugins , check this site .

You would then create a docker file where you define all these necessary e.g

FROM jenkins/jenkins:lts

ENV JENKINS_OPTS --prefix=/jenkins
RUN /usr/local/bin/  aws-credentials amazon-ecr amazon-ecs pipeline-maven


When the docker container is initialised this will automatically install all the plugins you define within it.

Apparently there is a way to all install tools directly through a groovy script as mentioned on the official github repo for jenkins but I have yet to try it .

This list of scripts might then be interesting to try out for automatic installation of tools e.g to automatically install a specific version of maven .