1.安装Java 8 (jdk 1.8) yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel #安装openjdk
2.下载rpm包(rpm包网址) sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
3.导出密钥(若之前已从Jenkins导入过密钥,“rpm--import”将失败,请忽略,继续执行下面) sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
4.安装Jenkins yum install -y jenkins
5.查看jenkins安装信息 [root@one ~]# rpm -ql jenkins /etc/init.d/jenkins /etc/logrotate.d/jenkins /etc/sysconfig/jenkins # jenkins配置文件 /usr/lib/jenkins # jenkins安装目录 /usr/lib/jenkins/jenkins.war /usr/sbin/rcjenkins /var/cache/jenkins /var/lib/jenkins # 默认JENKINS_HOME /var/log/jenkins # jenkins日志目录
6.配置jenkins #打开配置文件 vim /etc/sysconfig/jenkins #jenkins默认端口8080,若被占用或想更换端口,修改JENKINS_PORT的值 JENKINS_PORT="端口号"
7.启动jenkins systemctl start jenkins.service
8.运行jenkins项目,配置项目
#浏览器打开Jenkins项目(如果是云服务器,要在安全组规则中开启该端口) IP:你设置的端口 #解锁Jenkins 将服务器 /var/lib/jenkins/secrets/initialAdminPassword 中管理员密码输入到验证框 #若出现该Jenkins实例似乎已离线 解决方法:https://blog.csdn.net/qq_34272964/article/details/93500813 #按要求选择经典安装(新手建议选择)或则自定义安装,之后注册管理员帐号
9.卸载
卸载 rpm -e jenkins #rpm卸载 rpm -ql jenkins #检查是否卸载成功 find / -iname jenkins | xargs -n 1000 rm -rf 彻底删除残留文件