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

2023-12-21 12:32:03

安装步骤

官网的安装文档

导入秘钥

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 添加为例外。 您必须在下面的脚本中更改为要使用的端口

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

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

http://localhost:8080

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

?也可以执行命令查看密码

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

文章来源:https://blog.csdn.net/qq_34417433/article/details/135114672
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。