centos7安装Jenkins及其卸载

时间:2023-03-08 16:29:38

首先安装好Java(Java_home)

查看Java版本

# java -version

centos7安装Jenkins及其卸载

如果没安装,依照以下我的另一篇博客进行安装

https://www.cnblogs.com/djlsunshine/p/10164680.html

安装好之后

# java -version

centos7安装Jenkins及其卸载

方法一:yum安装

获取Jenkins安装源文件

# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo

centos7安装Jenkins及其卸载

导入公钥

# rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key

centos7安装Jenkins及其卸载

刷新yum缓存文件

# yum clean all

centos7安装Jenkins及其卸载

安装Jenkins

# yum install jenkins -y

centos7安装Jenkins及其卸载

配置文件修改(修改默认端口8080)

# vi /etc/sysconfig/jenkins

centos7安装Jenkins及其卸载

日志信息查看

/var/libs/jenkins/logs

/var/log/jenkins/jenkins.log

启动Jenkins报错

[root@localhost ~]# systemctl start jenkins
Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.

查看Jenkins状态

# systemctl status jenkins

centos7安装Jenkins及其卸载

按提示出现的命令,看看错误日志信息,原来刚刚没配置java路径,就默认去/usr/bin/java执行了,这里创建了一个软链接后,启动成功

# echo $JAVA_HOME

# ln -s /usr/java/jdk1.8/bin/java /usr/bin/java

# systemctl start jenkins

centos7安装Jenkins及其卸载

或者不建立软连接,直接修改默认Java路径

#vi /etc/init.d/jenkins

centos7安装Jenkins及其卸载

配置防火墙,放行Jenkins端口:

# firewall-cmd --add-port=8080/tcp

centos7安装Jenkins及其卸载

浏览器访问Jenkins主页

centos7安装Jenkins及其卸载

卸载Jenkins

rpm -e jenkins

删除遗留文件:

find / -iname jenkins | xargs -n 1000 rm -rf

centos7安装Jenkins及其卸载

参考博客

https://blog.csdn.net/linjingke32/article/details/77799878

方法二:rpm安装

官网上有详细的关于此的安装步骤

https://pkg.jenkins.io/redhat-stable/

centos7安装Jenkins及其卸载

点击下载一个Jenkins版本的rpm包,并上传到Linux中

导入公钥时报错了,因为我已经有公钥的了,所以忽视错误

centos7安装Jenkins及其卸载

安装

# rpm -ivh jenkins-2.150.1-1.1.noarch.rpm

centos7安装Jenkins及其卸载

centos7安装Jenkins及其卸载