一、系统优化
-
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
-
关闭selinux
sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0
二、安装Jenkins
sudo 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
安装JAVA11
yum install -y fontconfig java-11-openjdk
切换java到11版本,否则新版Jenkins不让启动
alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
\-----------------------------------------------
*+ 1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-6.oe2309.x86_64/jre/bin/java)
2 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.20.8-1.oe2309.x86_64/bin/java)
Enter to keep the current selection[+], or type selection number: 2
java -version
openjdk version "11.0.20" 2023-07-18
OpenJDK Runtime Environment Bisheng (build 11.0.20+8)
OpenJDK 64-Bit Server VM Bisheng (build 11.0.20+8, mixed mode, sharing)
安装Jenkins
dnf -y install jenkins
systemctl start jenkins
找初始化密码
cat /var/lib/jenkins/secrets/initialAdminPassword
admin
4jMzcjzz2KOU3cdbUnmA
然后,输入 Ip:8080,进行初始化操作。
三、修改workspace路径
华为欧拉系统默认/home路径为大空间,需要将默认装的Jenkins路径,修改到/home/jenkins下。
如果Jenkins已经使用,操作前提是你先把原来的数据mv到你需要的路径哦,copy前建议先关闭jenkins。
关闭jenkins
systemctl stop jenkins
查看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
vim /usr/lib/systemd/system/jenkins.service
查看本来的workspace路径,把数据移走
mv /var/lib/jenkins/ /home/
vim /usr/lib/systemd/system/jenkins.service
改资料
# $JENKINS_WEBROOT.
User=root
Group=root
# Directory where Jenkins stores its configuration and workspaces
Environment="JENKINS_HOME=/home/jenkins"
WorkingDirectory=/home/jenkins
systemctl daemon-reload 使得配置生效
service jenkins restart 重启jenkins
chkconfig jenkins on 设置开机自启动