Jenkins插件管理

一、加速镜像地址

地址:https://mirrors.tuna.tsinghua.edu.cn/

搜索Jenkins,找到并点击,进入后选中update,然后找到update-center,最后将链接地址复制到Jenkins中

安装完毕后更新插件将会更快,地址如下:

https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json

二、安装插件

三、手动上传插件

手动下载.hpi文件,然后系统管理--->插件管理--->高级--->上传插件即可。

四、导入已安装插件

注意插件和Jenkins版本需要一致,否则容易导致jenkins不稳定。

[root@localhost ~]# wget plugins.tar.gz
[root@localhost ~]# mv plugins/* /var/lib/jenkins/plugins/
[root@localhost ~]# chown -R jenkins.jenkins
[root@localhost ~]# systemctl restart jenkins

五、自动安装插件的方法

Jenkins 的 Docker 镜像的代码仓库里的 install-plugins.sh 脚本已经实现自动化安装,具体步骤如下:

Jenkins 官方 Docker 镜像中的自动化插件安装脚本:https://github.com/jenkinsci/docker/blob/master/install-plugins.sh

  • 将代码 clone 到 JENKINS_HOME 目录中:
[root@localhost ~]# cd $JENKINS_HOME
[root@localhost ~]#git clone https://github.com/zacker330/jenkins-install-plugins-shell.git
[root@localhost ~]#cd jenkins-install-plugins-shell
  • 在 plugins.txt 中添加要下载安装的插件名称

    Jenkins 插件有两个名称。一个叫 display name,一个叫 short name。搜索地址:https://plugins.jenkins.io/

    在 jenkins-install-plugins-shell 目录中,有一个 plugins.txt 文件,在文件中写入希望安装的插件及版本号。例如:

ansible:2.0
git:4.1.1

  • 执行安装
# Jenkins War 的路径,用于分析
[root@localhost ~]#export JENKINS_WAR_PATH=<Jenkins war文件的路径>
[root@localhost ~]#chmod +x install-plugins.sh jenkins-support
[root@localhost ~]#./install-plugins.sh < plugins.txt
  • 重启 Jenkins

    install-plugins 本质上做的事情就只是将插件从云端下载到 JENKINS_HOME 下的 plugins 目录中。要使安装的插件生效,还需要重启 Jenkins。

posted @ 2020-09-20 10:20  xyztank  阅读(153)  评论(0编辑  收藏  举报