福哥在通过docker安装jenkins的是时候发现插件无法安装,无论选什么都报找不到错误。
An error occurred during installation: No such plugin: cloudbees-folder
这是怎么回事啊?
原来docker的原则是尽可能的小,所以他们就把所有的插件全部都去掉了。。。

然后福哥在docker的官方介绍里面发现了解决方案,可以在制作Dockerfile的时候完成插件的安装。

插件版本可以通过下面的地址查看,福哥这里给的是git的版本,我们可以把地址最后面的git换成其他插件名称。
https://plugins.jenkins.io/git/

建立一个plugins.txt文件,里面放上需要安装的jenkins插件的信息,格式为:
[软件]:[版本]
文件换行符必须是LF,不能是CRLF,否则会报错。
福哥给出一部分插件的版本信息供童鞋们参考~~
cloudbees-folder:6.15 antisamy-markup-formatter:2.1 build-timeout:1.20 credentials-binding:1.27 timestamper:1.13 ws-cleanup:0.39 ant:1.11 gradle:1.37.1 workflow-aggregator:2.6 github-branch-source:2.11.1 pipeline-github-lib:1.0 pipeline-stage-view:2.19 git:4.7.2 subversion:2.14.4 ssh-slaves:1.32.0 matrix-auth:2.6.7 pam-auth:1.6 ldap:2.7 email-ext:2.83 mailer:1.34
通过jenkins镜像里面提供的一个shell脚本调用plugins.txt来安装插件。
/usr/local/bin/plugins.sh /usr/share/jenkins/plugins.txt

下面福哥给出Dockerfile,大家可以直接拿去使用~~
FROM jenkins:2.60.3 MAINTAINER Andy Bogate MAINTAINER tongfu@tongfu.net MAINTAINER https://tongfu.net/dockerfile MAINTAINER 2021/7/21 MAINTAINER v1.0.0 EXPOSE 8080 # plugins COPY plugins.txt /usr/share/jenkins/plugins.txt RUN /usr/local/bin/plugins.sh /usr/share/jenkins/plugins.txt
有的时候要多看看官方的介绍,可以避免我们绕弯路!!!