centos7.6环境jenkins升级到tomcat8.0.53和jenkins2.168版本

霍财
2023-12-01

Jenkins服务器:192.168.10.175
数据备份服务器:192.168.10.164

jenkins服务器报错不能访问,插件无法加载就不能正常获取代码,重启尝试解决无果,于是采用 如下方案:
将备份的服务器(上面有同步jenkins生产的数据)全新部署新版本的jenkins2.168,测试没有问题后将域名解析改到新的 192.168.10.164 上,这样用户没有感知就完成了问题修复


访问报错:插件不能加载,具体报错如下

There are dependency errors loading some plugins:
Pipeline: REST API Plugin v2.1
Pipeline: Input Step v2.0 failed to load. Fix this plugin first.
Pipeline: Shared Groovy Libraries v2.4
Pipeline: Groovy v2.14 failed to load. Fix this plugin first.
GitHub Branch Source Plugin v1.10
GitHub plugin v1.14.1 failed to load. Fix this plugin first.
HTML Publisher plugin v1.11
Matrix Project Plugin v1.0 failed to load. Fix this plugin first.
GitHub Organization Folder Plugin v1.5
Pipeline: Groovy v2.14 failed to load. Fix this plugin first.
Pipeline: Build Step v2.3
Pipeline: Supporting APIs v2.6 failed to load. Fix this plugin first.
Pipeline: Stage View Plugin v2.1
Pipeline: REST API Plugin v2.1 failed to load. Fix this plugin first.
Email Extension Template Plugin v1.0
Email Extension Plugin v2.43 failed to load. Fix this plugin first.
Pipeline: Nodes and Processes v2.5
Pipeline: Supporting APIs v2.1 failed to load. Fix this plugin first.
Permissive Script Security Plugin v0.5
You must update Jenkins from v2.19.1 to v2.107.3 or later to run this plugin.
Script Security Plugin v1.58 failed to load. Fix this plugin first.
Email Extension Plugin v2.51
Matrix Project Plugin v1.4 failed to load. Fix this plugin first.
Script Security Plugin v1.60
You must update Jenkins from v2.19.1 to v2.60.3 or later to run this plugin.
Warnings Plug-in v4.56
Static Analysis Utilities v1.77 failed to load. Fix this plugin first.
Jenkins Parameterized Trigger plugin v2.35.2
Conditional BuildStep v1.3.1 failed to load. Fix this plugin first.
Pipeline: Multibranch v2.9
Pipeline: Groovy v2.17 failed to load. Fix this plugin first.
Pipeline: Supporting APIs v2.8
Script Security Plugin v1.21 failed to load. Fix this plugin first.
Static Analysis Utilities v1.79
Matrix Project Plugin v1.4 failed to load. Fix this plugin first.
Pipeline Graph Analysis Plugin v1.2
Pipeline: Groovy v2.2 failed to load. Fix this plugin first.
Jenkins Workspace Cleanup Plugin v0.30
Matrix Project Plugin v1.7.1 failed to load. Fix this plugin first.
Jenkins Git plugin v3.0.0
Matrix Project Plugin v1.7.1 failed to load. Fix this plugin first.
Pipeline: Job v2.7
Pipeline: Supporting APIs v2.2 failed to load. Fix this plugin first.
Pipeline: Input Step v2.1
Pipeline: Supporting APIs v2.2 failed to load. Fix this plugin first.
Jenkins Multijob plugin v1.32
You must update Jenkins from v2.19.1 to v2.31 or later to run this plugin.
Conditional BuildStep v1.3.3 failed to load. Fix this plugin first.
GitLab Plugin v1.4.2
Jenkins Git plugin v2.4.1 failed to load. Fix this plugin first.
Environment Injector Plugin v2.1.6
Matrix Project Plugin v1.7 failed to load. Fix this plugin first.
Matrix Project Plugin v1.7.1
Script Security Plugin v1.13 failed to load. Fix this plugin first.
Pipeline: Groovy v2.19
Script Security Plugin v1.23 failed to load. Fix this plugin first.
Checkstyle Plug-in v3.46
Matrix Project Plugin v1.2.1 failed to load. Fix this plugin first.
Pipeline v2.4
Pipeline: Groovy v2.17 failed to load. Fix this plugin first.
Conditional BuildStep v1.3.6
Matrix Project Plugin v1.0 failed to load. Fix this plugin first.
GitHub plugin v1.22.2
Jenkins Git plugin v2.4.0 failed to load. Fix this plugin first.


备份的脚本:
# 每1小时同步一次jenkins的数据到本机
#05 */1 * * * /bin/bash /opt/rsync_jenkins2_chinasoft_cn_2local.sh >/dev/null 2>&1

# cat /opt/rsync_jenkins2_chinasoft_cn_2local.sh
#!/bin/bash

passfile=/data/www/.rsync/rsyncd.pass

/usr/local/rsync/bin/rsync -avrp -P --password-file=$passfile apache@192.168.10.175::apache/data/jenkins_home/ /data/jenkins_home/

/usr/local/rsync/bin/rsync -avrp -P --password-file=$passfile apache@192.168.10.175::apache/usr/local/worksh/jeninks_task/ /usr/local/worksh/jeninks_task/


部署新版本jenkins的步骤:

1.准备环境和软件:

a.安装java1.8.181

b.修改环境变量:
# vim /etc/profile

JENKINS_HOME=/data/jenkins_home

MAVEN_HOME=/usr/local/maven
PATH=$MAVEN_HOME/bin:$PATH
#JAVA_HOME=/usr/local/jdk
JAVA_HOME=/usr/java/jdk1.8.0_181-amd64
#JRE_HOME=/usr/local/jdk/jre
JRE_HOME=/usr/java/jdk1.8.0_181-amd64/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
#JAVA_OPTS='-server -Xms1024m -Xmx1024m XX:PermSize=128M -XX:MaxPermSize=256M'
export JAVA_HOME JRE_HOME PATH CLASSPATH MAVEN_HOME JENKINS_HOME

c.安装tomcat8.0.53,删除webapps下面所有文件,并将jenkins2.168.war解压到tomcat的webapps目录

2.启动tomcat,观察日志是否正常之前的数据都在,可以正常登录

发现报错,不能访问git,安装git命令,git clone可以正常使用

切换到apache用户下执行clone一次即可
部分使用apache用户的需要切换到 apache用户下执行,输入yes

[apache@jenkins/usr/local/tomcat]$ ssh -p2019 1.1.1.1


有一些小坑:
注意观察logs/catalina.out 如果加载的是jre1.7(旧版本就会有问题),一定要是jdk1.8.否则class无法解析
如下:
startup.VersionLoggerListener.log Java Home:             /usr/local/jdk1.7.0_80/jre

3.jenkins.chinaosft.cn 这个入口的proxy_pass要改为 192.168.10.164:8080

4.切换到apache用户下生成公钥,在git的web界面配置ssh-key
su apache
ssh-keygen -t rsa

5.部分jenkins任务使用了apache账号的ssh登录,需要进行免秘钥登录处理

 类似资料: