1.准备基础环境及Jenkins安装包
[root@localhost ~]# echo Jenkins > /etc/hostname [root@localhost ~]# hostname Jenkins --永久关闭防火墙和Selinux [root@Gitlab ~]# systemctl disable firewalld [root@Gitlab ~]# systemctl stop firewalld [root@Gitlab ~]# setenforce 0 [root@Gitlab ~]# sed -i 's/enforcing/disabled/' /etc/selinux/config [root@Gitlab ~]# getenforce
2.安装Jenkins跟Java
[root@Jenkins ~]# ls jenkins-2.283-1.1.noarch.rpm [root@Jenkins ~]# yum -y install java-11-openjdk-devel [root@Jenkins ~]# yum localinstall jenkins-2.283-1.1.noarch.rpm
3.启动Jenkins
[root@Jenkins ~]# java -version openjdk version "1.8.0_322" OpenJDK Runtime Environment (build 1.8.0_322-b06) OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode) [root@Jenkins ~]# systemctl start jenkins #启动Jenkins [root@Jenkins ~]# systemctl enable jenkins #配置自启动
4.配置Windows上域名解析(仅供测试,真实域名不需要)
5.查看Jenkins解锁密码
[root@Jenkins ~]# cat /var/lib/jenkins/secrets/initialAdminPassword 2eda0e3095d04446a05ace706c193e5e
注意:
如果想直接使用域名访问Jenkins,不加端口8080的话,可以安装Nginx来配置反向代理即可直接使用域名访问Jenkins!
6.配置登录Jenkins密码
7.修改Jenkins默认下载站点为国内
清华大学开源镜像站:https://mirror.tuna.tsinghua.edu.cn/jenkins/updates/
8.Jenkins中文汉化插件安装
Localization: Chinese (Simplified)
---> 安装重启后生效
Locale
---> 安装后需在Jenkins设置中配置语言
安装完重启一下Jenkins就可以了!
9.Jenkins版本升级
下载Jenkins升级war包
清华开源镜像站:https://mirror.tuna.tsinghua.edu.cn/jenkins/war-stable/或者 http://ftp-chi.osuosl.org/pub/jenkins/war-stable/ 下载最新的安装 war 包, 如果有新包的时候Jenkins后台也会有提示的,直接下载就好。(但那种最新的版本,存在不稳定性)
升级
[root@Jenkins ~]# ps -aux | grep jenkins #查找Jenkins运行路径 jenkins 11910 4.2 28.2 2378336 282124 ? Ssl 02:55 2:34 /etc/alternatives/java -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20 root 12689 0.0 0.0 112720 984 pts/0 R+ 03:56 0:00 grep --color=auto jenkins [root@Jenkins ~]# systemctl stop jenkins #停止jenkins服务 [root@Jenkins ~]# cd /usr/lib/jenkins/ #进入Jenkins.war运行路径 [root@Jenkins jenkins]# ls jenkins.war [root@Jenkins jenkins]# mv jenkins.war jenkins.war.bak #备份旧版本的Jenkins.war [root@Jenkins jenkins]# mv /root/jenkins.war . #拷贝新版本的Jenkins更新war包至Jenkins运行路径 [root@Jenkins jenkins]# ls jenkins.war jenkins.war.bak [root@Jenkins jenkins]# systemctl start jenkins #启动Jenkins