前言
学习Git时,需要用到此东东,然后学校的网并没有 魔法加速
功能,所以就搜索了一下在国内可以搭建Jenkins和加速的方法
配置yum仓库和epel源
这一步相信各位应该都会,然后还是贴一下吧:
## 下载centos7的repo源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
## 下载centos7的epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
## 全部下载完成后,生成缓存
yum clean all && yum makecache
下载jenkins rpm包
因为jenkins pkg服务器在国外的原因,国内的速度属实的慢,很多地方都会卡在这,这里给各位提供一个方法:
使用
中国科技大学镜像站的jenkins镜像,使用rpm -ivh进行安装
# 下载镜像到本地
wget https://mirrors.ustc.edu.cn/jenkins/redhat-stable/jenkins-2.263.4-1.1.noarch.rpm
# 安装rpm包
rpm -ivh jenkins-2.263.4-1.1.noarch.rpm
# 使用rpm -q 查看是否安装
rpm -q jenkins
# 如果出现以下内容即为安装成功
[root@master jenkins]# rpm -q jenkins
jenkins-2.263.4-1.1.noarch
安装java环境
按照官方文档的指示,本教程下载的版本对应java-1.8.0
所以在此我们安装以下java环境
# 安装java环境
yum -y install git java-1.8.0-openjdk*
# 刷新systemctl
systemctl daemon-reload
systemctl enable jenkins
## 如果上方代码执行提示:
## jenkins.service is not a native service, redirecting to /sbin/chkconfig.
## Executing /sbin/chkconfig jenkins on
## 可以不用理会,继续下面的操作
systemctl start jenkins
systemctl status jenkins
这个时候应该可以看到jenkins正常启动了
![图片[1]-Jenkins 安装 与 插件国内加速-魔王のBlog](https://kingcc.cn/wp-content/uploads/2021/03/image.png)
配置防火墙
安装完成后,我们查看一下jenkins的配置文件,查看端口是多少
cat /etc/sysconfig/jenkins | grep -vE "^\s*(#|$)"
正常情况下应该是这样:
![图片[2]-Jenkins 安装 与 插件国内加速-魔王のBlog](https://kingcc.cn/wp-content/uploads/2021/03/image-1.png)
然后我们知道端口为8080后,放行端口
# 开启防火墙(生产环境还是得稳重点)
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --reload
最后安照教案的操作来即可
Jenkins国内插件加速
教案上的加速的确可以,但是似乎 清华源无法在学校网络下使用,所以更换一下源即可
# 下载中国科技大学的update-center.json
wget -O /var/lib/jenkins/update-center.json http://mirrors.ustc.edu.cn/jenkins/updates/update-center.json
# 用sed替换下载源的国外地址到国内
sed -i 's#https://updates.jenkins.io/download/#http://mirrors.ustc.edu.cn/jenkins/#g' update-center.json &&
sed -i 's#http://www.google.com#https://www.baidu.com#g' update-center.json
# 进入Jenkins的update目录下
cd /var/lib/jenkins/updates
# 用sed替换官方的源
sed -i 's#https://updates.jenkins.io/download/#http://mirrors.ustc.edu.cn/jenkins/#g' default.json && sed -i 's#http://www.google.com#https://www.baidu.com#g' default.json
# 指定源用本地的
cd /var/lib/jenkins
vi hudson.model.UpdateCenter.xml
## 将<url>那块地址修改为本地的
<url>file:///var/lib/jenkins/update-center.json</url>
# 重启jenkins
systemctl restart jenkins
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
喜欢就支持一下吧
请登录后发表评论
注册
社交帐号登录