Notes catalog
Are they stumping you?
Plug-in installation failed or slow?
Have been loading after entering the initial password?
Can't connect to Jenkins?
Then this article will definitely help you_(:з」∠)_
First give you the solution (you can start reading directly from here!)
Change the configuration file of Jenkins (The following two steps must be completed)
Note: ①Please start Jenkins once ②The following operations are based on the mirror source of Tsinghua University as an example
- modify
hudson.model.UpdateCenter.xml
The first way:
/Root/.jenkins proceeds to the next, using vim editor
hudson.model.UpdateCenter.xml
todefault
underurl
modified as follows<sites> <site> <id>default</id> <url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url> </site> </sites>
The second way:
After starting Jenkins (it does not have to be initialized), go directly to http://localhost:8080/pluginManager/advanced, and fill in the two mirrors of one method in the UpdateSite input box at the bottom of the page One of the source URLs, then submit (submit)
- change
${JENKINS_HOME}/updates/default.json
My Jenkins home directory is under /root/.jenkins, so enter this directory first
cd /root/.jenkins/updates
When opening Jenkins for the first time, there is a path on the page that prompts for the initialization password)
The first way:
Use vim (or other editors, such as sublime) to edit default.json
vim default.json
Use vim's search and replace function to replace the url downloaded by the plugin
:1,$s/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g
Replace the url of Jenkins for network testing
:1,$s/http:\/\/www.google.com/https:\/\/www.baidu.com/g
The second way:
Use Linux's sed command in the home directory of Jenkins
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
Usage sed command interpretation :( slash
/
backslash\
escape)sed 's/要被取代的字串/新的字串/g'
Note: If Jenkins is started with sudo or root user, the sed command should also be completed with sudo or root user
Let’s talk about the reasons √
The purpose of the mirror source is simple to understand: it is the third-party groups and organizations that use their own servers to synchronize files and data on foreign official sources. In this way, when we need to download and use these files, we don't have to slowly obtain them from foreign servers, but directly obtain their early synchronized files through the domestic network. So we can see that we have to change the source when configuring some environments and software.
After talking about the purpose of the mirror source, let's take a look at why changing the Jenkins upgrade site following some online blogs does not solve the problem of slow downloads and frequent download failures.
In each open source mirror station, check Jenkins' update-center.json, you can find the following
The part marked in yellow is the official source of Jenkins, and the above content comes from the update-center.json file in the mirror source of Tsinghua University. Jenkins should obtain update-center.json according to the address of the upgrade site, and it actually points to the update resource ( (For example, plug-in ontology, Jenkins ontology, etc.) URL links are all in update-center.json.
The following conclusions can be drawn:
∵ Domestic link Jenkins is too slow or unable to connect
∴ We need mirror source
∵ update-center.json on the domestic mirror source = update-center.json on Jenkins official source
∴ After changing the url of the upgrade site, Jenkins will still download it according to the link in update-center.json
So we must also change the configuration under updates, which is the second step in the above solution
I hope that summing up the experience of stepping on the pit can better help the latecomers
Reference
- Jenkins installation plugin speed up -By Hellxz