方法一:替换配置文件的URL
替换 .jenkins/updates/default.json中的URL
需要
将 http://updates.jenkins-ci.org/download/
替换为 https://mirrors.tuna.tsinghua.edu.cn/jenkins/
将 http://www.google.com/
替换为 https://www.baidu.com/
替换方式 1
cd {你的Jenkins工作目录}/updates
vim default.json
:1,$s/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g
:1,$s/http:\/\/www.google.com/https:\/\/www.baidu.com/g
替换方式 2
cd {你的Jenkins工作目录}/updates
$ sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json
方法二:使用代理
step 1- 使用nginx自定义代理插件(清华镜像)
nginx 下载
http://nginx.org/download/nginx-1.18.0.tar.gz
http://nginx.org/download/nginx-1.18.0.zip
nginx配置文件(conf/nginx.conf)如下:
server
{
listen 80;
server_name mirrors.jenkins-ci.org;
location / {
proxy_redirect off;
proxy_pass https://mirrors.tuna.tsinghua.edu.cn/jenkins/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "";
proxy_set_header Accept-Language "zh-CN";
}
index index.html index.htm index.php;
#error_page 404 /404.html;
location ~ /\.
{
deny all;
}
access_log /var/log/nginx/jenkins_proxy.access.log main;
error_log /var/log/nginx//jenkins_proxy.error.log;
}
step 2-修改host文件
127.0.0.1 mirrors.jenkins-ci.org
windows : C:\Windows\System32\drivers\etc\hosts
linux : /etc/hosts
方法三(不推荐,好像不好用)
管理插件页面配置如下:
这个 URL 改成
http://mirror.xmission.com/jenkins/updates/update-center.json
或
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json