1、 配置yum源
参考地址:https://pkg.jenkins.io/redhat-stable/
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
2、 安装jenkins
# 最新版本jenkins已不支持java8
yum install fontconfig java-11-openjdk
yum install jenkins -y
- 建立java软链接
3、配置jenkins信息
/etc/sysconfig/jenkins
vim /etc/sysconfig/jenkins #编辑jenkins配置文件
JENKINS_PORT="10240" #修改jenkins监听端口(默认为8080)
JENKINS_USER="root" #修改jenkins文件权限操作用户(默认为"jenkins")
4、配置jenkins启动信息
/etc/init.d/jenkins
配置jenkins 启动信息(启动时,本地JAVA信息没有部署到jenkins)
## - 方式一:配置jenkins初始化文件添加java路径(大多数情况下失效)
vim /etc/init.d/jenkins #编辑jenkins启动配置
#修改candidates部分增加java可选路径:/usr/java/jdk1.8.0_333/bin/java
candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-11.0/bin/java
/usr/lib/jvm/jre-11.0/bin/java
/usr/lib/jvm/java-11-openjdk-amd64
/usr/bin/java
#以上是原来的,下面是新增本地的
/opt/module/jdk-17.0.1/bin/java## - 方式二:添加软连接,为自定义java环境创建快捷方式 /usr/bin/java(有时失效,初次启动较慢,多试几次)
#也可以直接添加软连接(快捷方式) --
ln -s /opt/module/jdk-17.0.1/bin/java /usr/bin/java
# 刷新配置
systemctl daemon-reload# 启动jenkins,并配置开机启动
systemctl start jenkins
systemctl enable jenkins# 查看初始密码
/var/lib/jenkins/secrets/initialAdminPassword
出现问题 : systemctl start jenkins 启动失败(
jenkins.service: Start request repeated too quickly.
)
修改端口 8080为10240(上面配置没有端口不知为啥没有生效)
/usr/lib/systemd/system/jenkins.service
Environment="JENKINS_PORT=10250"
高级设置
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json