如何将插件添加到docker jenkins? [英] How do i add plugins to a docker jenkins?
问题描述
在执行此操作时,我想使用dockerfile配置要安装的插件,然后将其构建为单独的jenkins + plugin映像. 我该怎么办?
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?
谢谢!
推荐答案
关于插件有两件事,一是预安装的插件,一是在jenkins启动后存储已安装的插件.因此,对于预安装的插件,您可以将撰写内容更改为以下
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
现在将jenkins_home
保留为已装入卷,将确保所有詹金更改都被保留.保留plugins.txt
将确保您的容器以预安装的插件开头.并且卷挂载将保留任何共享插件.文档中的重点
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
当jenkins容器启动时,它将检查JENKINS_HOME是否具有此参考内容,并在需要时将其复制到那里.它不会覆盖此类文件,因此,如果您从UI升级了某些插件,则下次启动时将不会还原它们.
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
这篇关于如何将插件添加到docker jenkins?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!