下面给你一份在 CentOS 上安装和配置 Jenkins 的实用指南(以 CentOS 7 / 8 为例,适用于大多数情况)。
# CentOS 7
yum install -y java-11-openjdk-devel
# CentOS 8
dnf install -y java-11-openjdk-devel
# 验证
java -version
wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install -y jenkins
# 或 CentOS 8
dnf install -y jenkins
systemctl enable jenkins
systemctl start jenkins
systemctl status jenkins
Jenkins 默认端口是 8080
# firewalld
firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --reload
# 或 iptables
iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
http://<服务器IP>:8080
cat /var/lib/jenkins/secrets/initialAdminPassword
复制密码粘贴到页面中。
按提示设置用户名、密码、邮箱
编辑配置文件:
vim /etc/sysconfig/jenkins
修改:
JENKINS_PORT="8080"
重启:
systemctl restart jenkins
cd /var/lib/jenkins/
vim hudson.model.UpdateCenter.xml
改为:
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
重启 Jenkins。
查看日志:
journalctl -u jenkins -f
常见原因:
systemctl status jenkins如果你告诉我:
我可以给你更具体的配置示例。