一、安装Jenkins
(1)首先确保已经安装jdk,如未安装,请参考 Java----CentOS7系统安装jdk1.8先安装jdk
(2)配置Jenkins源
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
(3)安装Jenkins
yum install epel-release
yum install java-11-openjdk-devel
yum install jenkins
(4)配置Jenkins端口号
vi /etc/sysconfig/jenkins
#监听端口
JENKINS_PORT="10003"
(5)配置用户
vi /etc/sysconfig/jenkins
#修改配置
$JENKINS_USER="root"
(6)修改目录权限
chown -R root:root /var/lib/jenkins
chown -R root:root /var/cache/jenkins
chown -R root:root /var/log/jenkins
(7)启动Jenkins
systemctl start jenkins
(8)网页打开Jenkins,如:在网页打开,如 http ://192.168.1.210:10003/
如下,根据页面提示找到密码并填入
[root@localhost ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
599ad742855948e0b8af280ad2e1f09f
(9)可以选择推荐的插件
(10)创建一个用户,如admin/admin
(11)如下,点击保存并完成安装
(12)至此,Jenkins搭建完成
二、卸载Jenkins
(1)停止服务
systemctl stop jenkins
(2)删除文件
rm -rf /etc/sysconfig/jenkins.rpmsave
rm -rf /var/cache/jenkins/
rm -rf /var/lib/jenkins/
rm -rf /var/log/jenkins
rm -rf /usr/lib/jenkins