一、Install & Check Java Env
Oracle官网下载Java: https://www.oracle.com/cn/
bash
# 拷贝到Jenkins服务器
scp Downloads/jdk-11.0.21_linux-aarch64_bin.tar.gz root@10.211.55.34:~
# 解压
mkdir -p /opt/java && tar -zxvf jdk-11.0.21_linux-aarch64_bin.tar.gz -C /opt/java
# 配置
vim ~/.bash_profile
# 内容 BEGIN
export JAVA_HOME=/opt/java/11.0.21
export JRE_HOME=/opt/java/11.0.21/jre
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
# 内容END
source ~/.bash_profile
[root@jenkins ~]# java -version
java version "11.0.21" 2023-10-17 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.21+9-LTS-193)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.21+9-LTS-193, mixed mode)
# 关闭防火墙
systemctl stop firewalld && systemctl disable firewalld
二、Add Jenkins Rpm & Install
Jenkins 2.357 及之后 LTS 版本开始,Jenkins 最低需要 Java 11。
Jenkins下载地址: https://mirrors.jenkins-ci.org/redhat/
bash
wget https://mirrors.jenkins-ci.org/redhat/jenkins-2.438-1.1.noarch.rpm --no-check-certificate
# 卸载需要rm -rf /var/lib/jenkins/* && rm -rf /etc/sysconfig/jenkins/*
yum localinstall jenkins-2.438-1.1.noarch.rpm -y
bash
# 修改jekins权限
vim /etc/sysconfig/jenkins
# JENKINS_USER="jenkins"
JENKINS_USER="root"
#JENKINS_PORT="8080"
JENKINS_PORT="80"
gpasswd -a root jenkins
vim /usr/lib/systemd/system/jenkins.service
User=root
# The Java home directory. When left empty, JENKINS_JAVA_CMD and PATH are consulted.
Environment="JAVA_HOME=/opt/java/jdk-11.0.21"
Environment="JENKINS_PORT=80"
systemctl daemon-reload
systemctl restart jenkins
三、常用命令
bash
# 启动
systemctl start jenkins
# 查看状态
systemctl status jenkins
# 设置开机启动
systemctl enable jenkins
# 查看日志
journalctl -u jenkins
四、测试访问
访问: http://jenkins.zhinian.com/
bash
# 查看初始密码
[root@jenkins ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
d45d72d2f01640a897921c24b286043e
保存并完成或选择使用admin登录,登录后改密码。
安装完成!
admin → configure → Apply → Save 修改密码并重新登录
Manage Jenkins → Configure System → Administrative monitors configuration
取消Update更新警告,Save、Apply
bash
cd /var/lib/jenkins/updates
sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json
# Plugin Manager URL替换
# https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
systemctl restart jenkins
安装插件
汉化
参考
https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/
jenkins忽略升级警告: https://blog.csdn.net/DynastyRumble/article/details/105664566