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!
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!
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