CentOS 安装jenkins笔记

  1. 安装 Java。目前一般jdk要求11以上,否则会报错

  2. 手动添加 Jenkins 仓库

先创建一个专门的Jenkins文件夹:mkdir jenkins

然后 执行

sudo curl -fsSL https://pkg.jenkins.io/redhat/jenkins.io.key -o /etc/pki/rpm-gpg/jenkins.io.key

然后,更新你的仓库配置文件。编辑或创建 /etc/yum.repos.d/jenkins.repo 文件,内容如下:

Jenkins

name=Jenkins

baseurl=https://pkg.jenkins.io/redhat/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/jenkins.io.key

enabled=1

  1. 清理 YUM 缓存并安装

sudo yum clean all

sudo yum makecache

再尝试安装Jenkins

sudo yum install jenkins

启动 Jenkins 服务

sudo systemctl start jenkins

sudo systemctl enable jenkins

  1. 检查 Jenkins 状态

sudo systemctl status jenkins

可能遇到的一些问题

1.例如会报以下错误:

bash 复制代码
Jul 14 14:24:53 iZ7xv7q3yjgje58dc089w0Z systemd[1]: start request repeated too quickly for jenkins.service
Jul 14 14:24:53 iZ7xv7q3yjgje58dc089w0Z systemd[1]: Failed to start Jenkins Continuous Integration Server.
Jul 14 14:24:53 iZ7xv7q3yjgje58dc089w0Z systemd[1]: Unit jenkins.service entered failed state.
Jul 14 14:24:53 iZ7xv7q3yjgje58dc089w0Z systemd[1]: jenkins.service failed.
Jul 14 14:24:59 iZ7xv7q3yjgje58dc089w0Z systemd[1]: [/usr/lib/systemd/system/jenkins.service:16] Unknown lvalue 'StartLimitBurst' in section 'Unit'
Jul 14 14:24:59 iZ7xv7q3yjgje58dc089w0Z systemd[1]: [/usr/lib/systemd/system/jenkins.service:17] Unknown lvalue 'StartLimitIntervalSec' in section 'Unit'

找到并编辑 /usr/lib/systemd/system/jenkins.service 文件,找到以下对应的两行配置

StartLimitBurst=5

StartLimitIntervalSec=0

删除或者注释掉

  1. 错误2 jdk版本不对应
bash 复制代码
Jul 14 17:43:15 iZ7xv7q3yjgje58dc089w0Z systemd[1]: Starting Jenkins Continuous Integration Server...
Jul 14 17:43:16 iZ7xv7q3yjgje58dc089w0Z jenkins[1147]: Error: A JNI error has occurred, please check your installation and try again
Jul 14 17:43:16 iZ7xv7q3yjgje58dc089w0Z jenkins[1147]: Exception in thread "main" java.lang.UnsupportedClassVersionError: executable/Main has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Jul 14 17:43:16 iZ7xv7q3yjgje58dc089w0Z jenkins[1147]: at java.lang.ClassLoader.defineClass1(Native Method)

排除Jenkins问题常用命令

journalctl -u jenkins.service -n 100 --no-pager

  • journalctl :是用于查看系统日志的工具,特别是与 systemd 相关的日志。它能帮助你查看服务的日志、错误信息以及其他系统事件。

  • -u jenkins.service :表示你要查看的是与 jenkins.service 相关的日志。这里的 -uunit 的缩写,jenkins.service 是 Jenkins 服务的名字。

  • -n 100:表示显示最后的 100 行日志。如果你想查看更多或更少的日志,可以调整这个数字。

  • --no-pager :表示日志输出时不使用分页工具(如 less)。通常,journalctl 会分页输出日志,但加上 --no-pager 之后,它会一次性输出所有日志,而不会等待用户输入以查看更多内容。

相关推荐
wan5555cn20 小时前
多张图片生成视频模型技术深度解析
人工智能·笔记·深度学习·算法·音视频
雁于飞1 天前
vscode中使用git、githup的基操
笔记·git·vscode·学习·elasticsearch·gitee·github
rannn_1111 天前
【Javaweb学习|实训总结|Week1】html基础,CSS(选择器、常用样式、盒子模型、弹性盒布局、CSS定位、动画),js(基本类型、运算符典例)
css·笔记·学习·html
Ro Jace1 天前
心灵笔记:第一性原理学习与实践
笔记
IT 小阿姨(数据库)1 天前
PgSQL监控死元组和自动清理状态的SQL语句执行报错ERROR: division by zero原因分析和解决方法
linux·运维·数据库·sql·postgresql·centos
aramae1 天前
C++ -- 模板
开发语言·c++·笔记·其他
小马学嵌入式~1 天前
嵌入式 SQLite 数据库开发笔记
linux·c语言·数据库·笔记·sql·学习·sqlite
hour_go1 天前
用户态与内核态的深度解析:安全、效率与优化之道
笔记·操作系统
虎头金猫1 天前
如何在Linux上使用Docker在本地部署开源PDF工具Stirling PDF:StirlingPDF+cpolar让专业操作像在线文档一样简单
linux·运维·ubuntu·docker·pdf·开源·centos
摇滚侠1 天前
Vue3入门到实战,最新版vue3+TypeScript前端开发教程,笔记03
javascript·笔记·typescript