参考jenkins官方: https://pkg.jenkins.io/redhat-stable/
第一步 前提
安装密钥:
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
WARNING: The gpg key use to sign our packages has been updated on 16th of April 2020, therefore you need to reimport it if you imported before this date.
警告:用于签署我们的软件包的gpg密钥已于2020年4月16日更新,因此如果在此日期之前导入,则需要重新导入。
结果如下:
[root@localhost prtainer]# sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
--2020-12-04 10:50:43-- https://pkg.jenkins.io/redhat-stable/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
长度:85
正在保存至: “/etc/yum.repos.d/jenkins.repo”
/etc/yum.repos.d/jenkins.repo 100%[=============================================================================>] 85 --.-KB/s 用时 0s
2020-12-04 10:50:44 (1.67 MB/s) - 已保存 “/etc/yum.repos.d/jenkins.repo” [85/85])
[root@localhost prtainer]# sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
[root@localhost prtainer]#
提示:
If you've previously imported the key from Jenkins, the rpm --import will fail because you already have a key. Please ignore that and move on.
如果您以前从Jenkins导入了密钥,那么rpm——import将失败,因为您已经有了一个密钥。请忽略这一点,继续前进。
第二步 验证
查看是否存在
yum search jenkins
执行结果
[root@localhost prtainer]# yum search jenkins
Jenkins-stable 2.9 kB/s | 19 kB 00:06
上次元数据过期检查:0:00:04 前,执行于 2020年12月04日 星期五 10时59分14秒。
================================================================= 名称 和 概况 匹配:jenkins =================================================================
jenkins.noarch : Jenkins Automation Server
python3-jenkins.noarch : Python bindings for the remote Jenkins API
第三步 安装
安装jenkins
yum install jenkins
执行结果
[root@localhost prtainer]# yum install jenkins
上次元数据过期检查:0:01:37 前,执行于 2020年12月04日 星期五 10时59分14秒。
依赖关系解决。
==============================================================================================================================================================
软件包 架构 版本 仓库 大小
==============================================================================================================================================================
安装:
jenkins noarch 2.263.1-1.1 jenkins 64 M
事务概要
==============================================================================================================================================================
安装 1 软件包
总下载:64 M
安装大小:64 M
确定吗?[y/N]: y
下载软件包:
[MIRROR] jenkins-2.263.1-1.1.noarch.rpm: Curl error (28): Timeout was reached for https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat-stable/jenkins-2.263.1-1.1.noarch.rpm [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds]
jenkins-2.263.1-1.1.noarch.rpm 947 kB/s | 64 MB 01:09
--------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 947 kB/s | 64 MB 01:09
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
运行脚本: jenkins-2.263.1-1.1.noarch 1/1
安装 : jenkins-2.263.1-1.1.noarch 1/1
运行脚本: jenkins-2.263.1-1.1.noarch 1/1
验证 : jenkins-2.263.1-1.1.noarch 1/1
已安装:
jenkins-2.263.1-1.1.noarch
完毕!
第四步 启动
启动jenkins
systemctl start jenkins
查看状态
systemctl status jenkins
结果
[root@localhost prtainer]# systemctl start jenkins
[root@localhost prtainer]# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; generated)
Active: active (running) since Fri 2020-12-04 11:06:25 CST; 5s ago
Docs: man:systemd-sysv-generator(8)
Process: 2871960 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
Tasks: 16 (limit: 48716)
Memory: 172.0M
CGroup: /system.slice/jenkins.service
└─2872050 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/>
12月 04 11:06:23 localhost.localdomain systemd[1]: Starting LSB: Jenkins Automation Server...
12月 04 11:06:23 localhost.localdomain runuser[2871968]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
12月 04 11:06:25 localhost.localdomain runuser[2871968]: pam_unix(runuser:session): session closed for user jenkins
12月 04 11:06:25 localhost.localdomain jenkins[2871960]: Starting Jenkins [ 确定 ]
12月 04 11:06:25 localhost.localdomain systemd[1]: Started LSB: Jenkins Automation Server.
第五步 修改端口
vim /etc/sysconfig/jenkins
....
## Type: string
## Default: "-Djava.awt.headless=true"
## ServiceRestart: jenkins
#
# Options to pass to java when running Jenkins.
#
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
## Type: integer(0:65535)
## Default: 8080
## ServiceRestart: jenkins
#
# Port Jenkins is listening on.
# Set to -1 to disable
#
JENKINS_PORT="8390"
## Type: string
## Default: ""
## ServiceRestart: jenkins
....
ESC
键后输入:wq
命令退出
重启jenkins
systemctl restart jenkins
结果
[root@localhost sysconfig]# systemctl restart jenkins
[root@localhost sysconfig]# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; generated)
Active: active (running) since Fri 2020-12-04 13:30:59 CST; 48s ago
Docs: man:systemd-sysv-generator(8)
Process: 2927198 ExecStop=/etc/rc.d/init.d/jenkins stop (code=exited, status=0/SUCCESS)
Process: 2927214 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
Tasks: 49 (limit: 48716)
Memory: 403.7M
CGroup: /system.slice/jenkins.service
└─2927261 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/>
12月 04 13:30:58 localhost.localdomain systemd[1]: Starting LSB: Jenkins Automation Server...
12月 04 13:30:58 localhost.localdomain runuser[2927222]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
12月 04 13:30:59 localhost.localdomain runuser[2927222]: pam_unix(runuser:session): session closed for user jenkins
12月 04 13:30:59 localhost.localdomain jenkins[2927214]: Starting Jenkins [ 确定 ]
12月 04 13:30:59 localhost.localdomain systemd[1]: Started LSB: Jenkins Automation Server.
第六步 访问管理页面
http://localhost:8390
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-bs1LzrdB-1607062585200)(http://www.lshserver.com:8388/markdown/_7VT445F67C8EKJ9S.png ‘’)]
第七步 获取密码
软件日志一般在var/log文件下面
more /var/log/jenkins.log
获取密码aa7bc1cb8b504fcd9b9980e1b79f720f
*************************************************************
*************************************************************
*************************************************************
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:
aa7bc1cb8b504fcd9b9980e1b79f720f
This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword
*************************************************************
*************************************************************
*************************************************************
第七步 插件选择
选择安装推荐的插件
或者选择插件来安装
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-O8Bg2QP7-1607062585217)(http://www.lshserver.com:8388/markdown/_0211HPCE7DTNKA9E.png ‘’)]
过程中可能出现安装失败部分插件安装失败,请重试或继续
,我们不管这个,点击继续
安装失败的插件可以等会再插件管理处查看失败原因或者继续安装。
第八步 创建管理员账号
第九步 实例配置
默认已经帮你生成好啦,点击保存并完成
以完成jenkins配置,当然,你也可以选择现在不要
之后进入管理界面重新设置这个值