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-2023.key
sudo yum upgrade
sudo yum -y install fontconfig java-17-openjdk-devel
# 也可以选择安装JDK21
# sudo yum -y install fontconfig java-21-openjdk-devel
sudo yum install -y jenkins-2.426.2
sudo systemctl daemon-reload
sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins
jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled; preset: disabled)
Active: active (running) since Thu 2023-12-21 11:24:15 CST; 3min 17s ago
Main PID: 624506 (java)
Tasks: 46 (limit: 48646)
Memory: 2.1G
CPU: 29.799s
CGroup: /system.slice/jenkins.service
└─624506 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080
12月 21 11:23:46 wgs-server jenkins[624506]: fc9be50e35fc4def85a77dade4a80b70
12月 21 11:23:46 wgs-server jenkins[624506]: This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword
12月 21 11:23:46 wgs-server jenkins[624506]: *************************************************************
12月 21 11:23:46 wgs-server jenkins[624506]: *************************************************************
12月 21 11:23:46 wgs-server jenkins[624506]: *************************************************************
12月 21 11:24:15 wgs-server jenkins[624506]: 2023-12-21 03:24:15.481+0000 [id=34] INFO jenkins.InitReactorRunner$1#onAttained: Completed initialization
12月 21 11:24:15 wgs-server jenkins[624506]: 2023-12-21 03:24:15.490+0000 [id=24] INFO hudson.lifecycle.Lifecycle#onReady: Jenkins is fully up and running
12月 21 11:24:15 wgs-server systemd[1]: Started Jenkins Continuous Integration Server.
12月 21 11:25:20 wgs-server jenkins[624506]: 2023-12-21 03:25:20.298+0000 [id=49] INFO h.m.DownloadService$Downloadable#load: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
12月 21 11:25:20 wgs-server jenkins[624506]: 2023-12-21 03:25:20.299+0000 [id=49] INFO hudson.util.Retrier#start: Performed the action check updates server successfully at the attempt #1
如果安装了防火墙,则必须将 Jenkins 添加为例外。 您必须在下面的脚本中更改为要使用的端口
YOURPORT=8080 PERM="--permanent" SERV="$PERM --service=jenkins" firewall-cmd $PERM --new-service=jenkins firewall-cmd $SERV --set-short="Jenkins ports" firewall-cmd $SERV --set-description="Jenkins port exceptions" firewall-cmd $SERV --add-port=$YOURPORT/tcp firewall-cmd $PERM --add-service=jenkins firewall-cmd --zone=public --add-service=http --permanent firewall-cmd --reload
首次访问新的 Jenkins 实例时,系统会要求您使用 自动生成的密码
http://localhost:8080
?也可以执行命令查看密码
sudo cat /var/lib/jenkins/secrets/initialAdminPassword