CentOS 7上安装 Jenkins 2.227 -- yum 方式

装插件的时候会报版本过低,建议安装 2.346

安装 Jenkins

#

[root@localhost ~]# ll /etc/yum.repos.d/

总用量 40

-rw-r--r--. 1 root root 1664 4月 8 2020 CentOS-Base.repo

-rw-r--r--. 1 root root 1309 4月 8 2020 CentOS-CR.repo

-rw-r--r--. 1 root root 649 4月 8 2020 CentOS-Debuginfo.repo

-rw-r--r--. 1 root root 314 4月 8 2020 CentOS-fasttrack.repo

-rw-r--r--. 1 root root 630 4月 8 2020 CentOS-Media.repo

-rw-r--r--. 1 root root 1331 4月 8 2020 CentOS-Sources.repo

-rw-r--r--. 1 root root 7577 4月 8 2020 CentOS-Vault.repo

-rw-r--r--. 1 root root 616 4月 8 2020 CentOS-x86_64-kernel.repo

-rw-r--r--. 1 root root 2081 3月 9 2022 docker-ce.repo

[root@localhost ~]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo

--2022-10-20 17:40:31-- https://pkg.jenkins.io/redhat/jenkins.repo

正在解析主机 pkg.jenkins.io (pkg.jenkins.io)... 151.101.110.133, 2a04:4e42:1a::645

正在连接 pkg.jenkins.io (pkg.jenkins.io)|151.101.110.133|:443... 已连接。

已发出 HTTP 请求,正在等待回应... 200 OK

长度:71

正在保存至: “/etc/yum.repos.d/jenkins.repo”

100%[==========================================>] 71 --.-K/s 用时 0s

2022-10-20 17:40:33 (1.56 MB/s) - 已保存 “/etc/yum.repos.d/jenkins.repo” [71/71])

# 添加成功后,查看

[root@localhost ~]# ll /etc/yum.repos.d/

总用量 48

-rw-r--r--. 1 root root 1664 11月 23 2020 CentOS-Base.repo

-rw-r--r--. 1 root root 1309 11月 23 2020 CentOS-CR.repo

-rw-r--r--. 1 root root 649 11月 23 2020 CentOS-Debuginfo.repo

-rw-r--r--. 1 root root 314 11月 23 2020 CentOS-fasttrack.repo

-rw-r--r--. 1 root root 630 11月 23 2020 CentOS-Media.repo

-rw-r--r--. 1 root root 1331 11月 23 2020 CentOS-Sources.repo

-rw-r--r--. 1 root root 8515 11月 23 2020 CentOS-Vault.repo

-rw-r--r--. 1 root root 616 11月 23 2020 CentOS-x86_64-kernel.repo

-rw-r--r--. 1 root root 2081 3月 9 2022 docker-ce.repo

-rw-r--r--. 1 root root 71 11月 30 2016 jenkins.repo

# 导入公钥

[root@localhost ~]# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

# yum 可以更新一下,

[root@localhost ~]# yum upgrade

# 安装 Jenkins 要加 --nogpgcheck 否则会报 jenkins-2.249.1-1.1.noarch.rpm 的公钥尚未安装

[root@localhost ~]# yum install jenkins-2.227 --nogpgcheck

已加载插件:fastestmirror, langpacks

Loading mirror speeds from cached hostfile

* base: mirrors.aliyun.com

* extras: mirrors.aliyun.com

* updates: mirrors.aliyun.com

正在解决依赖关系

--> 正在检查事务

---> 软件包 jenkins.noarch.0.2.227-1.1 将被 安装

--> 解决依赖关系完成

依赖关系解决

============================================================================================================

Package 架构 版本 源 大小

============================================================================================================

正在安装:

jenkins noarch 2.227-1.1 jenkins 63 M

事务概要

============================================================================================================

安装 1 软件包

总计:63 M

安装大小:63 M

Is this ok [y/d/N]: y

Downloading packages:

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

警告:RPM 数据库已被非 yum 程序修改。

正在安装 : jenkins-2.227-1.1.noarch 1/1

验证中 : jenkins-2.227-1.1.noarch 1/1

已安装:

jenkins.noarch 0:2.227-1.1

完毕!

# 查看软件包文件

[root@localhost ~]# rpm -ql jenkins

/etc/init.d/jenkins

/etc/logrotate.d/jenkins

/etc/sysconfig/jenkins # Jenkins 配置文件

/usr/bin/jenkins

/usr/lib/systemd/system/jenkins.service

/usr/sbin/rcjenkins

/usr/share/java/jenkins.war

/usr/share/jenkins

/usr/share/jenkins/migrate

/var/cache/jenkins

/var/lib/jenkins

/var/log/jenkins

[root@localhost ~]#

# 修改配置,jenkins安装成功后,默认的用户是jenkins,端口是8080,为了防止冲突,并且给用户赋权限,我们修改用户名和端口。

# 进到 VI 后 输入 /PORT 可以快速定位到 PORT 处,修改默认端口

[root@localhost ~]# vi /etc/sysconfig/jenkins

JENKINS_USER="root" #将用户改成 root 如果不改,启动时可能会报文件访问权限问题

JENKINS_PORT="8888" #修改默认端口

# 添加自启动

[root@localhost ~]# systemctl enable jenkins

Created symlink from /etc/systemd/system/multi-user.target.wants/jenkins.service to /usr/lib/systemd/system/jenkins.service.

[root@localhost ~]# systemctl start jenkins

# 查看服务状态

[root@localhost ~]# systemctl status jenkins

● jenkins.service - LSB: Jenkins Automation Server

Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)

Active: active (running) since 四 2022-10-20 18:53:28 CST; 23s ago

Docs: man:systemd-sysv-generator(8)

Process: 44903 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)

Main PID: 44248 (code=exited, status=1/FAILURE)

Tasks: 41

Memory: 943.0M

CGroup: /system.slice/jenkins.service

└─44933 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME...

10月 20 18:53:26 localhost.localdomain systemd[1]: Starting LSB: Jenkins Automation Server...

10月 20 18:53:26 localhost.localdomain runuser[44909]: pam_unix(runuser:session): session opened for user root...d=0)

10月 20 18:53:28 localhost.localdomain jenkins[44903]: Starting Jenkins [ 确定 ]

10月 20 18:53:28 localhost.localdomain systemd[1]: Started LSB: Jenkins Automation Server.

Hint: Some lines were ellipsized, use -l to show in full.

# 查看密码

[root@localhost ~]# cat /var/lib/jenkins/secrets/initialAdminPassword

d63a3493daee4a1645d7a105a0d24b5

[root@localhost ~]#

卸载 Jenkins

# 卸载jenkins服务

[root@localhost ~]# rpm -e jenkins

警告:/etc/sysconfig/jenkins 已另存为 /etc/sysconfig/jenkins.rpmsave

# 检查是否卸载成功

[root@localhost ~]# rpm -ql jenkins

未安装软件包 jenkins

[root@localhost ~]#

好文链接

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。