安装步骤

官网的安装文档

导入秘钥

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

更新yum源

sudo yum upgrade

安装JDK(已安装可忽略)

sudo yum -y install fontconfig java-17-openjdk-devel
# 也可以选择安装JDK21
# sudo yum -y install fontconfig java-21-openjdk-devel

安装Jenkins-2.426.2

sudo yum install -y jenkins-2.426.2

重新加载 systemd 守护进程配置文件

sudo systemctl daemon-reload 

启动 Jenkins

Jenkins 服务在启动时启动

sudo systemctl enable jenkins

启动 Jenkins 服务

sudo systemctl start jenkins

检查 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 实例时,系统会要求您使用 自动生成的密码

1. 浏览到(或您为其配置的任何端口) Jenkins)并等待 Unlock Jenkins 页面出现

Rocky Linux 9.3 安装 Jenkins 2.426.2 (超级详细版本)-LMLPHP

2. 从 Jenkins 控制台日志输出中,复制自动生成的 字母数字密码(在 2 组星号之间)

Rocky Linux 9.3 安装 Jenkins 2.426.2 (超级详细版本)-LMLPHP

 也可以执行命令查看密码

sudo cat /var/lib/jenkins/secrets/initialAdminPassword
12-22 11:28