https://github.com/lework/jenkins-update-center
https://lework.github.io/2020/03/05/jenkins-update-center/
https://www.haxi.cc/archives/change-jenkins-plugin-mirror.html
https://www.north-47.com/update-jenkins-plugins-behind-a-corporate-proxy/
https://zhuanlan.zhihu.com/p/125558756
一届腐、修改 UpdateCenter
UpdateCenter 指定獲取更新文件(update-center.json)的地址培他。
該文件(update-center.json)下載后,將會被修改后存入 .jenkins/updates/目錄意推。
修改 .jenkins/hudson.model.UpdateCenter.xml
如下
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url>
</site>
</sites>
sed 命令替換:
sed -i 's#https://updates.jenkins.io/update-center.json#https://cdn.jsdelivr.net/gh/lework/jenkins-update-center/updates/huawei/update-center.json#' /var/lib/jenkins/hudson.model.UpdateCenter.xml
如上也可在圖形界面修改,"Manage Jenkins" ---> "Manage Plugins" ---> "Advanced Settings" ---> "Update Site"
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json下載的是始終是最新的插件珊蟀,老版本的Jenkins不兼容的菊值。
根據(jù)當前版本,替換為https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/dynamic-stable-{$VERSION}/update-center.json
育灸,其中{$VERSION}
是當前Jenkins的版本腻窒。
如果不是LTS版本,則dynamic-stable-VERSION
要換成dynamic-VERSION
磅崭。
2023-06-28 09:17:43.752+0000 [id=42] INFO hudson.model.AsyncPeriodicWork#lambda$doRun$0: Started Download metadata
2023-06-28 09:17:43.786+0000 [id=42] INFO hudson.util.Retrier#start: Attempt #1 to do the action check updates server
2023-06-28 09:17:44.332+0000 [id=29] INFO jenkins.InitReactorRunner$1#onAttained: Completed initialization
2023-06-28 09:17:44.480+0000 [id=22] INFO hudson.WebAppMain$3#run: Jenkins is fully up and running
2023-06-28 09:18:02.065+0000 [id=42] WARNING h.m.DownloadService$Downloadable#updateNow: No tool installer metadata found for hudson.tasks.Maven.MavenInstaller
2023-06-28 09:18:02.066+0000 [id=42] INFO hudson.util.Retrier#start: Performed the action check updates server successfully at the attempt #1
2023-06-28 09:18:02.069+0000 [id=42] INFO hudson.model.AsyncPeriodicWork#lambda$doRun$0: Finished Download metadata. 18,316 ms
如上儿子,Jenkisn啟動后,開始下載更新文件砸喻。
倒數(shù)三行日志是下載update-center.json
的日志柔逼,update-center.json
會被轉(zhuǎn)義到 .jenkins/updates/default.json
文件。該文件保存著當前版本的依賴關(guān)系割岛。
案例:
Jenkins latest 版本2.412
愉适,但是需要部署低版本,以與生產(chǎn)環(huán)境2.277.1
保持一致癣漆。
在初始化插件的時候维咸,大部分安裝不上,會提示 Jenkins (2.289.1) or higher required 惠爽,插件依賴于更高版本的Jenkins腰湾。
二、修改從清華源下載插件
上面的配置修改的下載 update-center.json
的路徑疆股,update-center.json
內(nèi)下載插件的路徑任然源自 jenkins费坊。如下對插件的下載地址進行替換:
https://updates.jenkins.io/download 替換為 https://mirrors.tuna.tsinghua.edu.cn/jenkins
sed -i 's/https:\/\/updates.jenkins.io\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json
三、報錯解決 - Signature verification failed in update site
Jenkins 修改清華源后旬痹,提示日志報錯信息 “Signature verification failed in update site”
Jenkins: signature verification failed in update site 'default' (show details) - Stack Overflow
解決:Jenkins: signature verification failed in update site ‘default‘ (show details)_老徐愛編程的博客-CSDN博客
解決方式:
增加配置 -Dhudson.model.DownloadService.noSignatureCheck=true
java -Dhudson.model.DownloadService.noSignatureCheck=true -jar jenkins.2.277.1.war
附一:updates/default.json 文件解析
cat .jenkins/updates/default.json |jq 'keys'
[
"connectionCheckUrl",
"core",
"deprecations",
"generationTimestamp",
"id",
"plugins",
"signature",
"updateCenterVersion",
"warnings"
]
cat .jenkins/updates/default.json |jq '.plugins'
查看所有 plugins 信息附井,略
cat .jenkins/updates/default.json |jq '.plugins.zoom'
查看 zoom 插件詳細信息
cat .jenkins/updates/default.json |jq '.plugins."maven-plugin"'
查看 maven-plugin 插件詳細信息
{
"buildDate": "Apr 28, 2023",
"defaultBranch": "master",
"dependencies": [
{
"name": "commons-lang3-api",
"optional": false,
"version": "3.12.0-36.vd97de6465d5b_"
},
{
"name": "apache-httpcomponents-client-4-api",
"optional": false,
"version": "4.5.13-1.0"
},
{
"name": "javadoc",
"optional": false,
"version": "217.v905b_86277a_2a_"
},
{
"name": "jsch",
"optional": false,
"version": "0.1.55.2"
},
{
"name": "junit",
"optional": false,
"version": "1119.va_a_5e9068da_d7"
},
{
"name": "mailer",
"optional": false,
"version": "414.vcc4c33714601"
},
{
"name": "token-macro",
"optional": true,
"version": "293.v283932a_0a_b_49"
}
],
"developers": [
{
"developerId": "integer",
"name": "Kanstantsin Shautsou"
},
{
"developerId": "jglick",
"name": "Jesse Glick"
},
{
"developerId": "kohsuke",
"name": "Kohsuke Kawaguchi"
},
{
"developerId": "olamy",
"name": "Olivier Lamy"
},
{
"developerId": "olivergondza",
"name": "Oliver Gond?a"
},
{
"developerId": "aheritier",
"name": "Arnaud Héritier"
},
{
"developerId": "jtaboada",
"name": "Jose Blas Camacho Taboada"
}
],
"excerpt": "This plugin provides a deep integration between Jenkins and Maven. It adds support for automatic triggers between projects depending on SNAPSHOTs as well as the automated configuration of various Jenkins publishers such as Junit.",
"gav": "org.jenkins-ci.main:maven-plugin:3.22",
"issueTrackers": [
{
"reportUrl": "https://www.jenkins.io/participate/report-issue/redirect/#16033",
"type": "jira",
"viewUrl": "https://issues.jenkins.io/issues/?jql=component=16033"
}
],
"labels": [
"builder"
],
"name": "maven-plugin",
"popularity": 142274,
"previousTimestamp": "2023-03-01T03:31:07.00Z",
"previousVersion": "3.21",
"releaseTimestamp": "2023-04-28T07:42:14.00Z",
"requiredCore": "2.332.1",
"scm": "https://github.com/jenkinsci/maven-plugin",
"sha1": "iVu4F5xFOzzMzV6ISJRxU6nqwNQ=",
"sha256": "a1vbnllzvvspscrWflgLVOYTJttgWa8xzw37Xb0U7G0=",
"size": 5488120,
"title": "Maven Integration",
"url": "https://updates.jenkins.io/download/plugins/maven-plugin/3.22/maven-plugin.hpi",
"version": "3.22",
"wiki": "https://plugins.jenkins.io/maven-plugin"
}
下載插件的地址是,"url": "https://updates.jenkins.io/download/plugins/maven-plugin/3.22/maven-plugin.hpi"