jenkins 从CentOS6 迁移到CentOS7记录

  

一、备份

  任何迁移操作一定要做好备份

  一般主要包括:

  主目录默认路径:/var/lib/jenkins

  安装包:/usr/share/java/jenkins.war 

    系统文件:/etc/hosts

  自定义脚本

二、CentOS7 安装jenkins

sudo wget -O /etc/yum.repos.d/jenkins.repo \
    https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum upgrade
# Add required dependencies for the jenkins package
sudo yum install java-11-openjdk
sudo yum install jenkins
sudo systemctl daemon-reload


参考官方文档:https://www.jenkins.io/doc/book/installing/linux/#red-hat-centos

 

三、数据迁移

因为jenkins所有配置、数据为文件,所以基本拷贝相关目录就可以了

1.  迁移jenkins主目录

 主目录默认路径:/var/lib/jenkins

   注意:实际以自己的jenkins : Dashboard > Manage Jenkins > Configure System 显示为准

2. 迁移jenkins安装包

 这里建议先使用旧的jenkins.war ,确认没问题后,可以在新服务器通过管理平台升级

 安装包路径:/usr/share/java/jenkins.war 

3. 第三方安装包:svn 

这里比较常见的一个问题是,svn证书、svn用户等问题,

因为jenkins默认以jenkins用户启动,所以需要在jenkins用户下保存密码,

可以临时修改jenkins等用户,

vi /etc/passwd

修改 jenkins:x:996:991:Jenkins Automation Server:/var/lib/jenkins:/bin/false

jenkins:x:996:991:Jenkins Automation Server:/var/lib/jenkins:/bin/bash

 

# 登陆jenkins用户
su jenkins

# 执行svn命令如下
svn ls --username=svnuser https://domain.com/svn/

# 根据提示  p 永久信任
Error validating server certificate for 'https://domain.com/svn/':
 - The certificate is not issued by a trusted authority. Use the
   fingerprint to validate the certificate manually!
 - The certificate hostname does not match.
Certificate information:
 - Hostname: WIN-SVN
 - Valid: from Tue, 08 Aug 2007 12:20:58 GMT until Fri, 06 Aug 2037 12:20:58 GMT
 - Issuer: WIN-SVN
 - Fingerprint: 23:65:af:c7:c0:d0:b4:83:f3:ff:e3:4b:9c:d5:6f:97:51:35:30:24
(R)eject, accept (t)emporarily or accept (p)ermanently? p

# 保存svn密码

ATTENTION!  Your password for authentication realm:

   <https://domain.com> VisualSVN Server

can only be stored to disk unencrypted!  You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible.  See the documentation for details.

You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/var/lib/jenkins/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? 
Please type 'yes' or 'no': yes
 
还有一个常见的问题是jenkisn的svn插件的svn版本,
如果版本跟系统不匹配,可能会出现各种各样的问题
例如:
svn: E155036: Please see the 'svn upgrade' command
svn: E155036: Working copy '/var/lib/jenkins/workspace/project' is too old (format 8, created by Subversion 1.4)
 

4. 主目录权限设置 

  chown -R jenkins:jenkins /var/lib/jenkins

5. 无密登陆的ssh私钥 

 

四、启动服务

# 设置开机自动启动
sudo systemctl enable jenkins

# 启动jenkins服务
sudo systemctl start jenkins

# 检查jenkins状态
sudo systemctl status jenkins

 

五、登陆jenkins

如果迁移成功,登陆以后所有等任务、配置都会跟之前的配置一样,

但实际使用中可能还会有部分插件、定制组建不兼容的问题,根据提示一一解决就好。

 


 

posted @ 2023-02-08 18:49  i学笔记  阅读(130)  评论(0编辑  收藏  举报