CentOS 7.9 安装 Jenkins 2.361.2
一、CentOS 7.9 安装 Jenkins 2.361.2
1 下载地址:https://www.jenkins.io/download
2 简介
Jenkins是一个Java开发的开源持续集成工具,广泛用于项目开发,具有自动化构建、测试和部署等功能,它的运行需要Java环境。
二、Jenkins Redhat Packages
To use this repository, run the following command:
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
If you've previously imported the key from Jenkins, the rpm --import
will fail because you already have a key. Please ignore that and move on.
yum install fontconfig java-11-openjdk
yum install jenkins
The rpm packages were signed using this key:
pub rsa4096 2020-03-30 [SC] [expires: 2023-03-30]
62A9756BFD780C377CF24BA8FCEF32E745F2C3D5
uid Jenkins Project <jenkinsci-board@googlegroups.com>
sub rsa4096 2020-03-30 [E] [expires: 2023-03-30]</jenkinsci-board@googlegroups.com>
You will need to explicitly install a supported Java runtime environment (JRE), either from your distribution (as described above) or another Java vendor (e.g., Adoptium).
三、启动
# 启动Jenkins
systemctl start jenkins
# 设置开机启动
systemctl enable jenkins
# 查看Jenkins状态
systemctl status jenkins
# 关闭Jenkins
systemctl stop jenkins
在浏览器打开Jenkins控制面板 http://IP:8080/
如果一直浏览器一直是这个界面,就需要修改一下Jenkins的配置文件,然后重启Jenkins,然后等待浏览器出现输入密码的界面表示Jenkins启动成功
vim /var/lib/jenkins/hudson.model.UpdateCenter.xml
systemctl restart jenkins
# https://updates.jenkins.io/update-center.json
# https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
如果不记得密码,可以通过以下命令找回
cat /var/lib/jenkins/secrets/initialAdminPassword
四、配置Jenkins
进入jenkins配置文件
vim /etc/sysconfig/jenkins
JENKINS_HOME="/var/lib/jenkins" # jenkins的工作路径
JENKINS_JAVA_CMD=""
JENKINS_USER="jenkins" # 默认的jenkins用户是jenkins
JENKINS_PORT="8080" # 修改jenkins的默认端口
查看系统8080端口是否被占用
netstat -nlt |grep 8080
五、防火墙开启8080端口
# 关闭防火墙
systemctl stop firewalld
# 开放3306端口命令
firewall-cmd --zone=public --add-port=8080/tcp --permanent
# 配置立即生效
firewall-cmd --reload
云主机需配置安全组
在入方向规则,允许8080放行
六、服务卸载
# 卸载jenkins服务
rpm -e jenkins
# 检查是否卸载成功
rpm -ql jenkins
# 彻底删除残留文件
find / -name jenkins | xargs rm -rf