温馨提示×

centos如何连jenkins库

小樊
44
2026-09-30 10:35:28
栏目: 智能运维

在 CentOS 上“连 Jenkins 库”通常指 把 Jenkins 的官方 YUM 软件源(repository)配置到 CentOS 中,以便用 yum/dnf 安装或升级 Jenkins。下面按常见场景给你说明。


一、CentOS 7 / 8 添加 Jenkins 官方 YUM 源(最常用)

1. 导入 Jenkins GPG 密钥

sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

2. 添加 Jenkins YUM 仓库

sudo tee /etc/yum.repos.d/jenkins.repo <<'EOF'
[jenkins]
name=Jenkins-stable
baseurl=https://pkg.jenkins.io/redhat-stable
enabled=1
gpgcheck=1
EOF

3. 安装 Jenkins

sudo yum clean all
sudo yum makecache
sudo yum install jenkins

二、CentOS Stream / CentOS 8(用 dnf)

sudo dnf install epel-release -y
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

sudo tee /etc/yum.repos.d/jenkins.repo <<'EOF'
[jenkins]
name=Jenkins-stable
baseurl=https://pkg.jenkins.io/redhat-stable
enabled=1
gpgcheck=1
EOF

sudo dnf install jenkins -y

三、如果你说的是“连 Jenkins 的构建依赖库(Maven/NPM 等)”

如果是 Jenkins 任务里连代码仓库或依赖库:

连 Git 仓库

git clone https://github.com/your/repo.git

Maven 私库(示例)

在 pom.xml 或 settings.xml 中配置:

<repository>
  <id>nexus</id>
  <url>http://nexus.example.com/repository/maven-public/</url>
</repository>

四、如果你说的是“CentOS 客户端连 Jenkins 服务”

只需网络可达 + 浏览器或 API:

curl http://jenkins-server-ip:8080

五、常见问题

1. GPG 校验失败

gpgcheck=0   # 临时关闭(不推荐生产)

2. Java 未安装

Jenkins 需要 Java 11 或 17:

sudo yum install java-11-openjdk -y

如果你能具体说一下:

  • ✅ 是 装 Jenkins
  • ✅ 还是 Jenkins 连 CentOS
  • ✅ 还是 CentOS 连 Jenkins API / 仓库 / 私服

我可以直接给你对应命令或配置示例。

0 踩