1. 安装Jenkins
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo --no-check-certificate
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
yum install -y fontconfig java-17-openjdk
dnf -y install jenkins
systemctl start jenkins
2. 启动报错处理
Failed to start Jenkins Continuous Integration Server
java -jar /usr/share/java/jenkins.war
Running with Java 11 from /usr/lib/jvm/java-11-openjdk-11.0.20.8-1.oe2309.x86_64, which is older than the minimum required version (Java 17).
Supported Java versions are: [17, 21]
看看报错情况,大多是最新版本的jenkins需要的jdk最低版本问题,按提示下载最新版,并选择新版java版本,再次java -jar
yum install -y fontconfig java-17-openjdk
alternatives --config java
3.查看初始密码
cat /var/lib/jenkins/secrets/initialAdminPassword
4. 开启防火墙
firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --reload
5. 修改workspace路径
前提是你先把原来的数据copy到你需要的路径哦,copy前建议先关闭jenkins。
(1) 关闭jenkins
systemctl stop jenkins
(2) 查看jenkins安装路径
rpm -ql jenkins
/usr/bin/jenkins
/usr/lib/systemd/system/jenkins.service
/usr/share/java/jenkins.war
/usr/share/jenkins/migrate
/var/cache/jenkins
/var/lib/jenkins
(3) vim /usr/lib/systemd/system/jenkins.service 查看本来的workspace路径,把数据移走,并授权jenkins用户
# Unix account that runs the Jenkins daemon
# Be careful when you change this, as you need to update the permissions of
# $JENKINS_HOME, $JENKINS_LOG, and (if you have already run Jenkins)
# $JENKINS_WEBROOT.
User=jenkins
Group=jenkins
# Directory where Jenkins stores its configuration and workspaces
Environment="JENKINS_HOME=/var/lib/jenkins"
WorkingDirectory=/var/lib/jenkins
移走,授权jenkins用户
mv /var/lib/jenkins/ /home/
usermod -a -G root jenkins
chown -R jenkins /home/jenkins
(4) vim /usr/lib/systemd/system/jenkins.service 改资料
# Directory where Jenkins stores its configuration and workspaces
Environment="JENKINS_HOME=/home/jenkins"
WorkingDirectory=/home/jenkins
(5) vim /etc/profile
export JENKINS_HOME=/home/jenkins
(6) 重启
systemctl daemon-reload
service jenkins restart
chkconfig jenkins on
标签:java,lib,--,250103,usr,workspace,jenkins,Jenkins
From: https://www.cnblogs.com/amadeuslee/p/18650178