Anolis系统下安装Jenkins
1.安装java、maven
yum install -y java-17-openjdk-devel maven git wget
2.配置环境变量
1.查看java和maven所在目录
[root@localhost ~]# which java
/usr/bin/java
[root@localhost bin]# ll /usr/bin/java
lrwxrwxrwx 1 root root 22 4月 1 17:20 /usr/bin/java -> /etc/alternatives/java
[root@localhost bin]# ll /etc/alternatives/java
lrwxrwxrwx 1 root root 66 4月 2 10:02 /etc/alternatives/java -> /usr/lib/jvm/java-17-openjdk-17.0.14.0.7-3.0.2.an8.x86_64/bin/java
[root@localhost ~]# mvn -v
Apache Maven 3.5.4 (Red Hat 3.5.4-5)
Maven home: /usr/share/maven
Java version: 1.8.0_442, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.442.b06-2.0.2.an8.x86_64/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "5.10.134-16.2.axs8.x86_64", arch: "amd64", family: "unix"
#如果存在多个java版本,切换自己需要的java版本执行
sudo alternatives --config java
2.配置环境变量
vi /etc/profile
添加以下内容:
JENKINS_JAVA_CMD="/usr/lib/jvm/java-17-openjdk-17.0.14.0.7-3.0.2.an8.x86_64/bin"
export MAVEN_HOME=/usr/share/maven
export PATH=$PATH:$MAVEN_HOME/bin
3.下载jenkins
[root@localhost ~]# wget https://repo.huaweicloud.com/jenkins/redhat-stable/jenkins-2.479.2-1.1.noarch.rpm
--2025-04-01 16:34:13-- https://repo.huaweicloud.com/jenkins/redhat-stable/jenkins-2.479.2-1.1.noarch.rpm
正在解析主机 repo.huaweicloud.com (repo.huaweicloud.com)... 116.130.221.26, 116.130.221.25, 116.130.221.22
正在连接 repo.huaweicloud.com (repo.huaweicloud.com)|116.130.221.26|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:90991760 (87M) [application/octet-stream]
正在保存至: “jenkins-2.479.2-1.1.noarch.rpm”jenkins-2.479.2-1.1.noarch.rpm 100%[======================================================================================>] 86.78M 45.0MB/s 用时 1.9s 2025-04-01 16:34:15 (45.0 MB/s) - 已保存 “jenkins-2.479.2-1.1.noarch.rpm” [90991760/90991760])[root@localhost ~]#
4.安装jenkins
[root@localhost ~]# rpm -ivh jenkins-2.479.2-1.1.noarch.rpm
警告:jenkins-2.479.2-1.1.noarch.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 45f2c3d5: NOKEY
准备中... ################################# [100%]
正在升级/安装...1:jenkins-2.479.2-1.1 ################################# [100%]
[root@localhost ~]#
5.开启8080端口
firewall-cmd --zone=public --add-port=8080/tcp --permanent
systemctl restart firewalld #重启
6.设置jenkins开机自启
[root@localhost ~]# systemctl status jenkins.service
● jenkins.service - Jenkins Continuous Integration ServerLoaded: loaded (/usr/lib/systemd/system/jenkins.service; disabled; vendor preset: disabled)Active: inactive (dead)
[root@localhost ~]# systemctl start jenkins.service
[root@localhost ~]# systemctl enable jenkins.service
Synchronizing state of jenkins.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable jenkins
Created symlink /etc/systemd/system/multi-user.target.wants/jenkins.service → /usr/lib/systemd/system/jenkins.service.
[root@localhost ~]# systemctl status jenkins.service
● jenkins.service - Jenkins Continuous Integration ServerLoaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled; vendor preset: disabled)Active: active (running) since Tue 2025-04-01 16:44:33 CST; 23s agoMain PID: 988053 (java)Tasks: 65 (limit: 99900)Memory: 1.8GCGroup: /system.slice/jenkins.service└─988053 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=80804月 01 16:44:11 localhost.localdomain jenkins[988053]: Please use the following password to proceed to installation:
4月 01 16:44:11 localhost.localdomain jenkins[988053]: 8a4c57a69f2046b78e18467cf1983299
4月 01 16:44:11 localhost.localdomain jenkins[988053]: This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword
4月 01 16:44:11 localhost.localdomain jenkins[988053]: *************************************************************
4月 01 16:44:33 localhost.localdomain jenkins[988053]: 2025-04-01 08:44:33.685+0000 [id=57] INFO jenkins.InitReactorRunner$1#onAttained: Completed initiali>
4月 01 16:44:33 localhost.localdomain jenkins[988053]: 2025-04-01 08:44:33.719+0000 [id=30] INFO hudson.lifecycle.Lifecycle#onReady: Jenkins is fully up an>
4月 01 16:44:33 localhost.localdomain systemd[1]: Started Jenkins Continuous Integration Server.
4月 01 16:44:35 localhost.localdomain jenkins[988053]: 2025-04-01 08:44:35.914+0000 [id=83] INFO h.m.DownloadService$Downloadable#load: Obtained the update>
4月 01 16:44:35 localhost.localdomain jenkins[988053]: 2025-04-01 08:44:35.915+0000 [id=83] INFO hudson.util.Retrier#start: Performed the action check upda>
4月 01 16:44:35 localhost.localdomain jenkins[988053]: 2025-04-01 08:44:35.916+0000 [id=83] INFO hudson.model.AsyncPeriodicWork#lambda$doRun$1: Finished Do>[root@localhost ~]#
7.查看默认登录密码
[root@localhost ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
8a4c57a69f2046b78e18467cf1983299
8.浏览器访问Jenkins登录(访问连接:http://IP:8080)
9.Jenkins设置中文显示
点击 Dashboard>Manage Jenkins>Manager Plugin
下载
Localization: Chinese (Simplified)
Locale localization-support