问题产生:
随着Jenkins的使用,我们会不断的安装新的插件,此时有的插件是需要Jenkins的版本达到一定要求才可以的,如当我要安装Role-based Authorization Stratege插件时,就出现了警告,需要Jenkins版本至少为2.222.1,如果强行安装便会安装失败,因为我的Jenkins版本为2.190.3,版本过低。

强行安装失败

解决办法:升级Jenkins版本
我们知道Jenkins是一个web项目,所以最关键的就是项目的war包
1、下载war包
去https://updates.jenkins-ci.org/download/war/下载最新的war包,如图

如果Jenkins项目里检测到有新版本时其实是会有提示的,可以看到最新版本为2.293,这时点击下载即可。

2、替换 war 包。
登录Jenkins所在的服务器,找到jenkins.war包所在目录,将新版本替换过去,稳妥起见备份下之前的jenkins.war。
1、找到jenkins.war包所在路径
[root@localhost jenkins]# ps aux | grep jenkins
root 1689 1.4 3.3 4619408 327204 ? Ssl 15:49 3:21 /etc/alternatives/java
-Djava.awt.headless=true
-DJENKINS_HOME=/var/lib/jenkins
-jar /usr/lib/jenkins/jenkins.war
--logfile=/var/log/jenkins/jenkins.log
--webroot=/var/cache/jenkins/war
--httpPort=8888 --debug=5
--handlerCountMax=100 --handlerCountMaxIdle=20
root 3162 0.0 0.0 112720 968 pts/0 R+ 19:48 0:00 grep
--color=auto jenkins
2、备份原有的jenkins.war
[root@localhost jenkins]# cd /usr/lib/jenkins/
[root@localhost jenkins]# ll
总用量 70252
-rw-r--r--. 1 root root 71937427 5月 21 19:40 jenkins.war
[root@localhost jenkins]# mv jenkins.war /root/temp
3、关闭jenkins服务,并查看状态,确保关闭成功
[root@localhost jenkins]# systemctl stop jenkins
[root@localhost jenkins]# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
Active: inactive (dead) since 五 2021-05-21 20:20:31 CST; 1s ago
Docs: man:systemd-sysv-generator(8)
Process: 3351 ExecStop=/etc/rc.d/init.d/jenkins stop (code=exited, status=0/SUCCESS)
Process: 3282 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
5月 21 20:19:05 localhost.localdomain systemd[1]: Starting LSB: Jenkins Automation Server...
5月 21 20:19:05 localhost.localdomain jenkins[3282]: Starting Jenkins [ 确定 ]
5月 21 20:19:05 localhost.localdomain systemd[1]: Started LSB: Jenkins Automation Server.
5月 21 20:20:30 localhost.localdomain systemd[1]: Stopping LSB: Jenkins Automation Server...
5月 21 20:20:31 localhost.localdomain jenkins[3351]: Shutting down Jenkins [ 确定 ]
5月 21 20:20:31 localhost.localdomain systemd[1]: Stopped LSB: Jenkins Automation Server.
4、将下载的最新jenkins.war包放入/usr/lib/jenkins目录
mv jenkins.war /usr/lib/jenkins/
5、再次启动jenkins
[root@localhost jenkins]# systemctl start jenkins
6、此时再通过浏览器登录到jenkins,发现右下角版本已经更新为最新的2.293

现在便可以成功安装需要的插件了

升级Jenkins:从war包升级解决插件版本要求
本文指导如何因Jenkins插件需求升级,通过下载并替换war包实现从2.190.3版本升级到2.293,确保后续插件安装顺利。
1216

被折叠的 条评论
为什么被折叠?



