首先安装好Java(Java_home)
查看Java版本
# java -version
如果没安装,依照以下我的另一篇博客进行安装
https://www.cnblogs.com/djlsunshine/p/10164680.html
安装好之后
# java -version
方法一:yum安装
获取Jenkins安装源文件
# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
导入公钥
# rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
刷新yum缓存文件
# yum clean all
安装Jenkins
# yum install jenkins -y
配置文件修改(修改默认端口8080)
# vi /etc/sysconfig/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
按提示出现的命令,看看错误日志信息,原来刚刚没配置java路径,就默认去/usr/bin/java执行了,这里创建了一个软链接后,启动成功
# echo $JAVA_HOME
# ln -s /usr/java/jdk1.8/bin/java /usr/bin/java
# systemctl start jenkins
或者不建立软连接,直接修改默认Java路径
#vi /etc/init.d/jenkins
配置防火墙,放行Jenkins端口:
# firewall-cmd --add-port=8080/tcp
浏览器访问Jenkins主页
卸载Jenkins
rpm -e jenkins
删除遗留文件:
find / -iname jenkins | xargs -n 1000 rm -rf
参考博客
https://blog.csdn.net/linjingke32/article/details/77799878
方法二:rpm安装
官网上有详细的关于此的安装步骤
https://pkg.jenkins.io/redhat-stable/
点击下载一个Jenkins版本的rpm包,并上传到Linux中
导入公钥时报错了,因为我已经有公钥的了,所以忽视错误
安装
# rpm -ivh jenkins-2.150.1-1.1.noarch.rpm