jenkins官网Redhat Jenkins Packages
一、配置jenkins yum源
bash
#下载并配置jenkins源
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo --no-check-certificate
#配置jenkins证书
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
二、配置jenkins安装环境
bash
#1、安装jdk17
#如果安装先卸载 yum安装的卸载方式
yum remove java*
#安装包安装的卸载方式 清理 /etc/profile的环境变量配置
#创建jdk17下载路径
mkdir -p /usr/local/java/
#切换路径
cd /usr/local/java
#安装wget 如果安装可以跳过
yum install -y wget
#下载jdk17
wget https://download.java.net/java/GA/jdk17.0.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_linux-x64_bin.tar.gz
#解压jdk17
tar -xzvf openjdk-17.0.1_linux-x64_bin.tar.gz -C /usr/local/java/
#配置环境变量
sed -i '$a export JAVA_HOME=/usr/local/java/jdk-17.0.1' /etc/profile
sed -i '$a export JRE_HOME=${JAVA_HOME}/jre' /etc/profile
sed -i '$a export CLASSPATH=.:${JAVA_HOME}/lib:${JREHOME}/lib:$CLASSPATH' /etc/profile
sed -i '$a export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin' /etc/profile
sed -i '$a export PATH=$PATH:${JAVA_HOME}/bin:${JRE_HOME}/bin' /etc/profile
#重新加载环境变了
source /etc/profile
#验证jdk
java -version
#2、安装fontconfig
yum -y install fontconfig
#3、安装git
yum -y install git
三、安装配置jenkins
bash
#安装jenkins
yum -y install jenkins
#配置jenkins配置文件
vim /lib/systemd/system/jenkins.service
##############jenkins.service############
# The Java home directory. When left empty, JENKINS_JAVA_CMD and PATH are consulted.
#Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
Environment="JAVA_HOME=/usr/local/java/jdk-17.0.1" #添加jdk引用路径
# Port to listen on for HTTP requests. Set to -1 to disable.
# To be able to listen on privileged ports (port numbers less than 1024),
# add the CAP_NET_BIND_SERVICE capability to the AmbientCapabilities
# directive below.
Environment="JENKINS_PORT=18080" #修改端口号
####################################################
#重新加载systemctl
systemctl daemon-reload
#启动jenkins
systemctl start jenkins
#查看密码 首次登录要用/var/lib/jenkins/secrets/initialAdminPassword
cat /var/lib/jenkins/secrets/initialAdminPassword
四、修改防火墙配置
bash
#1、彻底关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
#2、开放jenkins端口 18080
firewall-cmd --permanent --add-port=18080/tcp
firewall-cmd --reload
firewall-cmd --query-port=18080/tcp
五、设置jenkins中文汉化
1、下载插件
安装完成之后退出重新登录jenkins 即可设置为中文 不用进行第二步 如果想也可以进行第二步设置