CentOS7环境下安装Jenkins
JDK安装详细见: JDK安装详细步骤
jenkins安装
Jenkins源添加
**注意: **
问题1、在添加Jenkins源时会出现以下错误
这是由于没有安装wget软件包的原因
进行wget软件包的安装:
- yum -y install wget
问题2、ERROR: cannot verify pkg.jenkins.io’s certificate, issued by ‘/C=US/O=Let’s Encrypt/CN=R3’:
Issued certificate has expired.
[root@localhost kit]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo --2022-02-11 09:17:59-- https://pkg.jenkins.io/redhat-stable/jenkins.repo Resolving
pkg.jenkins.io (pkg.jenkins.io)… 151.101.2.133, 151.101.66.133, 151.101.130.133, … Connecting to pkg.jenkins.io (pkg.jenkins.io)|151.101.2.133|:443… connected. ERROR: cannot verify pkg.jenkins.io’s certificate, issued by ‘/C=US/O=Let’s Encrypt/CN=R3’:
Issued certificate has expired.
To connect to pkg.jenkins.io insecurely, use `–no-check-certificate’.
解决方式:
sudo yum install -y ca-certificates
在重新添加Jenkins源:
- sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.repo
导入公钥
- sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
效果如图:
安装jenkins
- yum install jenkins
注意:
在安装是会报错, 如果没有错误请跳过以下操作, 错误如下:
问题1、Error: Nothing to do
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cache
No package jenkins available.
Error: Nothing to do
这个错误说明yum设置源出现错误,在这里更换yum源,步骤如下:
-
清除磁盘空间
yum clean all
说明:
yum clean headers清除header
yum clean packages清除下载的rpm包
yum clean all全部清除。
-
建立缓存
yum makecache
-
装一下 epel 源
yum install epel-release
说明: EPEL(Extra Packages for Enterprise Linux)是由 Fedora 社区打造,为 RHEL
及衍生发行版如 CentOS等提供高质量软件包的项目。装上了 EPEL,就像在 Fedora 上一样,可以通过 yum install xxxx,即可安装很多以前需要编译安装的软件。
解决问题后,再进行安装即可(效果如图)
修改Jenkins端口号
vi /etc/sysconfig/jenkins
启动Jenkins服务
修改配置文件
开始之前在配置文件配置/etc/init.d下的jenkins文件中增加现有jdk的路径:
vi /etc/init.d/jenkins
Esc → Shift+: → wq(保存) 即可
启动Jenkins服务
service jenkins start
关闭Jenkins服务
service jenkins stop
访问Jenkins
查看密码
journalctl -u jenkins.service
结束!!!