1.yum 下离线安装 Jenkins
cd /tmp
wget https://pkg.jenkins.io/redhat-stable/jenkins-2.361.2-1.1.noarch.rpm
yum localinstall jenkins-2.361.2-1.1.noarch.rpm
## 启动jenkins(默认端口8080)
systemctl start jenkins
## 查看日志
tail -f /var/log/jenkins/jenkins.log
如果启动失败,请看这里:
Jenkins 默认会在以下目录按顺序搜寻 JDK,一旦找到一个可用的即返回。
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/lib/jvm/java-11.0/bin/java
/usr/lib/jvm/jre-11.0/bin/java
/usr/lib/jvm/java-11-openjdk-amd64
/usr/bin/java
如果系统的以上位置都未安装 JDK,启动时就会报错,这是可以考虑建立软连接:
ln -s /opt/java/jdk1.8.0_231/bin/java /usr/bin/java
2.yum 在线安装 Jenkins
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install jenkins
#yum update jenkins
# 如果报Delta RPMs disabled because /usr/bin/applydeltarpm not installed
yum provides '*/applydeltarpm'
yum install deltarpm
还可以实现在线更新
yum update jenkins
## 安装后需要重启jenkins
systemctl restart jenkins
3.Jenkins 国内环境 插件下载加速
- 1.第一步 修改配置
打开地址:http://xxx/pluginManager/advanced
修改原升级站点:https://updates.jenkins.io/update-center.json
改为:https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
- 2.第二步 修改默认配置json文件
/var/lib/jenkins/updates/default.json
替换所有插件下载的url
cd /var/lib/jenkins/updates
sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json
替换连接测试url
sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json
- 3.重启jenkins
http://xxx/restart
4.jenkins占用内存较大问题
为了解决此问题,打开/etc/init.d/jenkins
找到JENKINS_JAVA_OPTIONS
修改成或新增:
在
JENKINS_LOCKFILE
下操作
#JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Xms256m -Xmx256m -XX:MaxNewSize=256m -XX:MaxPermSize=256m"
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Xms256m -Xmx384m"
5.备份
当前官方的备份还在开发中:https://www.jenkins.io/zh/doc/book/system-administration/backing-up/
可以先使用备份/恢复插件 ThinBackup
6.关闭更新提示
访问/manage/configure
,找到管理监控配置
,取消选中"Jenkins Update Notification“和"Deprecated Plugin Monitor"。
7.构建通知
- 先安装插件
[Qy Wechat Notification Plugin版本1.1.3](https://plugins.jenkins.io/qy-wechat-notification)
- 配置job
评论区