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!
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.
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 .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With