自动化部署之jenkins升级和备份
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自动化部署之jenkins升级和备份相关的知识,希望对你有一定的参考价值。
jenkins升级
(1)查看war包所在的目录 [[email protected] ~]# rpm -ql jenkins /etc/init.d/jenkins /etc/logrotate.d/jenkins /etc/sysconfig/jenkins /usr/lib/jenkins /usr/lib/jenkins/jenkins.war /usr/sbin/rcjenkins /var/cache/jenkins /var/lib/jenkins /var/log/jenkins (2)下载最新稳定版的war包 [[email protected] ~]# wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/war/2.46/jenkins.war --2017-12-21 14:56:10-- https://mirrors.tuna.tsinghua.edu.cn/jenkins/war/2.46/jenkins.war Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.6.178, 2402:f000:1:416:101:6:6:177 Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.6.178|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 68663046 (65M) [application/java-archive] Saving to: ‘jenkins.war’ 36% [====================================================> ] 24,829,614 707KB/s eta 60s
当前jenkins版本为2.32.2
(3)停止jenkins服务 [[email protected] ~]# service jenkins stop Stopping jenkins (via systemctl): [ OK ] (4)备份原来的war包,并拷贝最新版本war包到/usr/lib/jenkins目录下 [[email protected] ~]# cd /usr/lib/jenkins/ [[email protected] jenkins]# mv jenkins.war jenkins-2.32.2.war.bak [[email protected] jenkins]# mv /root/jenkins.war . [[email protected] jenkins]# service jenkins start Starting jenkins (via systemctl): [ OK ] [[email protected] jenkins]# netstat -tulnp |grep 8080 tcp6 0 0 :::8080 :::* LISTEN 47298/java 成功升级到jenkins 2.46版本
2.jenkins备份
在jenkins界面创建一些项目,这里使用rsync,主要是为了保持备份的属性,如果使用scp或cp有时会导致文件属性的改变而导致jenkins异常。
(1)创建备份目录 [[email protected] ~]# mkdir /data/backup/jenkins -p (2)备份/var/lib/jenkins目录 [[email protected] ~]# rsync -raz --delete --progress /var/lib/jenkins /data/backup/jenkins/ (3)删除/var/lib/jenkins/ [[email protected] ~]# rm -rf /var/lib/jenkins/ [[email protected] ~]# service jenkins restart Restarting jenkins (via systemctl): Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details. [FAILED] [[email protected] ~]# service jenkins status JENKINS_HOME directory does not exist: /var/lib/jenkins (4)恢复备份 [[email protected] ~]# rsync -raz --delete /data/backup/jenkins/jenkins /var/lib/ [[email protected] ~]# service jenkins restart Restarting jenkins (via systemctl): [ OK ]
以上是关于自动化部署之jenkins升级和备份的主要内容,如果未能解决你的问题,请参考以下文章