在 CentOS 下安装和配置 Jenkins,一般流程如下(以 CentOS 7/8 为例,适用于大多数场景):
# CentOS 7/8
yum install -y java-11-openjdk-devel
# 或
yum install -y java-1.8.0-openjdk
验证:
java -version
# 导入 Jenkins 源
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
systemctl start jenkins
systemctl enable jenkins
查看状态:
systemctl status jenkins
firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --reload
浏览器访问:
http://服务器IP:8080
cat /var/lib/jenkins/secrets/initialAdminPassword
复制到网页中。
编辑:
vi /etc/sysconfig/jenkins
修改:
JENKINS_PORT="8080"
重启:
systemctl restart jenkins
Manage Jenkins → Global Tool Configuration
mvn clean package)查看日志:
journalctl -u jenkins
或:
cat /var/log/jenkins/jenkins.log
Jenkins 2.3xx 推荐 Java 11+
server {
listen 80;
server_name jenkins.example.com;
location / {
proxy_pass http://127.0.0.1:8080;
}
}
如果你需要:
可以告诉我你的具体使用场景,我可以给你更细的配置方案。