Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i add plugins to a docker jenkins?

while doing this, I would like to use a dockerfile to configure which plugins will be installed and then build it as a separate jenkins+plugin image. How do I do so?

Thank you!

like image 746
Joe Doe Avatar asked Sep 16 '17 15:09

Joe Doe


People also ask

Is there a Docker plugin for Jenkins?

Jenkins ConfigurationDocker plugin is a "Cloud" implementation. You'll need to edit Jenkins system configuration (Jenkins -> Manage -> System configuration) and add a new Cloud of type "Docker". Configure Docker (or Swarm standalone) API URL with required credentials. The test button lets you check the connection.

What are Docker plugins?

A plugin is a process running on the same or a different host as the docker daemon, which registers itself by placing a file on the same docker host in one of the plugin directories described in Plugin discovery. Plugins have human-readable names, which are short, lowercase strings. For example, flocker or weave .


1 Answers

There are two things about plugins one is preinstalled plugins and one is storing the installed plugins after jenkins is up. So for pre-installed plugins you will change your compose to below

docker-compose.yml

version: '2'

services:
  jenkins:
    build:
      context: .
    container_name: jenkins
    restart: always
    ports:
      - 80:8080
    volumes:
      - ./jenkins_home:/var/jenkins_home

.dockerignore

jenkins_home

Dockerfile

FROM jenkins/jenkins:lts
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt

plugins.txt

cucumber-testresult-plugin:0.8.2
pam-auth:1.1
matrix-project:1.4.1
script-security:1.13

Now keep jenkins_home as volume mounted will make sure all your jenkin changes are persisted. Keeping a plugins.txt will make sure that your container starts with pre-installed plugins. And the volume mount will persist any of the shared plugin. A key point from documentation

When jenkins container starts, it will check JENKINS_HOME has this reference content, and copy them there if required. It will not override such files, so if you upgraded some plugins from UI they won't be reverted on next start.

Please refer to below links if you need additional and latest information

https://github.com/jenkinsci/docker/blob/master/README.md

like image 117
Tarun Lalwani Avatar answered Sep 28 '22 18:09

Tarun Lalwani