当前位置: 首页 > news >正文

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

3. 清理 YUM 缓存并安装

sudo yum clean all
sudo yum makecache

再尝试安装Jenkins

sudo yum install jenkins

启动 Jenkins 服务

sudo systemctl start jenkins
sudo systemctl enable jenkins


4. 检查 Jenkins 状态

sudo systemctl status jenkins

可能遇到的一些问题

1.例如会报以下错误:

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

删除或者注释掉

2.  错误2  jdk版本不对应

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 之后,它会一次性输出所有日志,而不会等待用户输入以查看更多内容。

http://www.lryc.cn/news/587643.html

相关文章:

  • LVS的集群技术和分布式
  • RabbitMQ中队列长度限制(Queue Length Limit)详解
  • Docker Desktop 挂载本地Win系统配置指南:Redis/MySQL/RabbitMQ持久化与自启设置
  • 【第一章编辑器开发基础第二节编辑器布局_3间距控制(4/4)】
  • RabbitMQ的介绍与安装
  • RabbitMQ的几个模式
  • Redis单线程详解
  • Advanced Database Systems: History of Databases
  • 代数基本定理最简短的证明
  • C++ 中常见的字符串定义方式及其用法
  • 正运动与您相聚2025青岛国际工业自动化技术及装备展览会!
  • 前端字体使用操作
  • YOLOv11调参指南
  • 管程! 解决互斥,同步问题的现代化手段(操作系统os)
  • Linux操作系统从入门到实战(八)详细讲解编译器gcc/g++编译步骤与动静态库链接
  • Rocket常见问题及解决方案
  • H2 与高斯数据库兼容性解决方案:虚拟表与类型处理
  • 第12章:【系统架构设计师】系统架构设计-数据流风格
  • Oracle中的INSTR函数
  • 衡石科技技术手册--仪表盘过滤控件详解
  • 空间智能-李飞飞团队工作总结(至2025.07)
  • Spring Cloud分布式配置中心:架构设计与技术实践
  • 2025前端面试题
  • (懒人救星版)CNN_Kriging_NSGA2_Topsis(多模型融合典范)深度学习+SCI热点模型+多目标+熵权法 全网首例,完全原创,早用早发SCI
  • 【前端:Typst】--let关键字的用法
  • ethers.js-5–和solidity的关系
  • Popover API 实战指南:前端弹层体验的原生重构
  • 七、深度学习——RNN
  • C语言-流程控制
  • 详解从零开始实现循环神经网络(RNN)