1. 检查是否安装JDK
[root@localhost ~]# rpm -qa |grep java
显示空则表示未安装JDK,若安装直接进入第二步
安装JDK1.8
查看java版本列表
[root@localhost ~]# yum list java*
安装jdk1.8 64位
[root@localhost ~]# yum install -y java-1.8.0-openjdk.x86_64
查看jdk版本
[root@localhost ~]# java -version openjdk version "1.8.0_282" OpenJDK Runtime Environment (build 1.8.0_282-b08) OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)
2. 安装jenkins
[root@localhost ~]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo [root@localhost ~]# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key [root@localhost ~]# yum install -y jenkins
3. 修改默认端口
[root@localhost ~]# vim /etc/sysconfig/jenkins
找到JENKINS_PORT="8080"改为JENKINS_PORT=“9099”
4. 添加防火墙规则
[root@localhost ~]# firewall-cmd --zone=public --add-port=9099/tcp –permanent
重新载入规则
[root@localhost ~]# firewall-cmd --reload
5. 重启jenkins服务
[root@localhost ~]# systemctl restart jenkins
查看服务状态
[root@localhost ~]# systemctl status jenkins
Active: active (running)代表服务已经启动
6. 获得管理员密码
浏览器访问http://IP:9099
查看密码
[root@localhost ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
7. 设置使用清华源安装插件
[root@localhost ~]# cd /var/lib/jenkins/updates/ [root@localhost updates]# sed -i 's/https:\/\/updates.jenkins-ci.org\/download/http:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json
重启jenkins服务
[root@localhost updates]# systemctl restart jenkins
8. 安装插件
浏览器访问http://IP:9099
9. 设置管理员账户