一:安装JDK

清华源官方网站: https://mirrors.tuna.tsinghua.edu.cn

[root@keepalived-127 ~]# yum install java-1.8.0-openjdk -y
Jenkins 安装过程中会要求安装推荐插件或自定义插件,默认是从Jenkins 官网拉取插件,国内网络访问Jenkins 官网比较慢,导致安装时间长。

[root@keepalived-127 ~]# java -version

二:安装nginx代理,指向清华源

      Jenkins 安装时会默认从updates.jenkins-ci.org 拉取,我们可以采用nginx代理的方式将其代理至mirrors.tuna.tsinghua.edu.cn ,方法如下:

1:安装nginx,并且配置host 解析:

[root@keepalived-127 ~]# vi /etc/hosts
127.0.0.1 updates.jenkins-ci.org


2:指向清华源

[root@keepalived-127 conf.d]# cat jenkins.conf 

    server {
        listen       80;
        server_name updates.jenkins-ci.org;
        location /download/plugins {
                proxy_next_upstream http_502 http_504 error timeout invalid_header;
                proxy_set_header Host mirrors.tuna.tsinghua.edu.cn;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
                rewrite /download/plugins/(.*) /jenkins/plugins/$1 break;
                proxy_pass https://mirrors.tuna.tsinghua.edu.cn;
       }

 }

三:重启nginx

[root@keepalived-127 conf.d]# nginx -s reload

四:安装jenkins,会快很多

[root@keepalived-127 ~]# wget https://pkg.jenkins.io/redhat/jenkins-2.156-1.1.noarch.rpm

[root@keepalived-127 ~]# rpm -ivh jenkins-2.156-1.1.noarch.rpm

[root@keepalived-127 src]# systemctl start jenkins
[root@keepalived-127 src]# systemctl status jenkins

五:浏览器打开

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐