mirror of
https://github.com/lework/jenkins-update-center.git
synced 2025-02-20 07:48:21 +02:00
add
This commit is contained in:
parent
3e9940509d
commit
ce70137925
107
README.md
107
README.md
@ -1,2 +1,107 @@
|
||||
# jenkins-update-center
|
||||
# jenkins-update-center
|
||||
|
||||

|
||||
[](https://www.jsdelivr.com/package/gh/lework/jenkins-update-center)
|
||||
|
||||
Jenkins mirror update center generator
|
||||
|
||||
|
||||
## Update time
|
||||
|
||||
Updated daily at 1 AM UTC
|
||||
|
||||
|
||||
|
||||
## Mirror site
|
||||
|
||||
- tencent https://mirrors.cloud.tencent.com/jenkins/
|
||||
- huawei https://mirrors.huaweicloud.com/jenkins/
|
||||
- tsinghua https://mirrors.tuna.tsinghua.edu.cn/jenkins/
|
||||
- ustc https://mirrors.ustc.edu.cn/jenkins/
|
||||
- bit http://mirror.bit.edu.cn/jenkins/
|
||||
|
||||
|
||||
|
||||
**file update-center.json**
|
||||
|
||||
| Site | Source | CDN |
|
||||
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
|
||||
| tencent | https://raw.githubusercontent.com/lework/jenkins-update-center/master/updates/tencent/update-center.json | https://cdn.jsdelivr.net/gh/lework/jenkins-update-center/updates/tencent/update-center.json |
|
||||
| huawei | https://raw.githubusercontent.com/lework/jenkins-update-center/master/updates/huawei/update-center.json | https://cdn.jsdelivr.net/gh/lework/jenkins-update-center/updates/huawei/update-center.json |
|
||||
| tsinghua | https://raw.githubusercontent.com/lework/jenkins-update-center/master/updates/tsinghua/update-center.json | https://cdn.jsdelivr.net/gh/lework/jenkins-update-center/updates/tsinghua/update-center.json |
|
||||
| ustc | https://raw.githubusercontent.com/lework/jenkins-update-center/master/updates/ustc/update-center.json | https://cdn.jsdelivr.net/gh/lework/jenkins-update-center/updates/ustc/update-center.json |
|
||||
| bit | https://raw.githubusercontent.com/lework/jenkins-update-center/master/updates/bit/update-center.json | https://cdn.jsdelivr.net/gh/lework/jenkins-update-center/updates/bit/update-center.json |
|
||||
|
||||
**mirror site speed test**
|
||||
|
||||
```bash
|
||||
curl -sSL https://cdn.jsdelivr.net/gh/lework/jenkins-update-center/speed-test.sh | bash
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Usage mirror site
|
||||
|
||||
1. Upload custom CA file.
|
||||
|
||||
```bash
|
||||
[ ! -d /var/lib/jenkins/update-center-rootCAs ] && mkdir /var/lib/jenkins/update-center-rootCAs
|
||||
wget https://cdn.jsdelivr.net/gh/lework/jenkins-update-center/rootCA/update-center.crt -o /var/lib/jenkins/update-center-rootCAs/update-center.crt
|
||||
chown jenkins.jenkins -R /var/lib/jenkins/update-center-rootCAs
|
||||
```
|
||||
|
||||
2. Change Update Site url.
|
||||
|
||||
Go to `Jenkins` → `Manage Jenkins` → `Manage Plugins` → `Advanced` → Update Site and submit URL to your `https://cdn.jsdelivr.net/gh/lework/jenkins-update-center/updates/tsinghua/update-center.json`
|
||||
|
||||
|
||||
|
||||
## Steps to create local mirror of Jenkins update center:
|
||||
|
||||
1. Clone code:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/iamtrump/jenkins-update-center.git
|
||||
```
|
||||
|
||||
2. Generate self-signed certificate:
|
||||
|
||||
```bash
|
||||
cd jenkins-update-center
|
||||
openssl genrsa -out rootCA/update-center.key 2048
|
||||
openssl req -new -x509 -days 3650 rootCA/update-center.key -out rootCA/update-center.crt
|
||||
```
|
||||
|
||||
3. Rsync into your www root directory:
|
||||
|
||||
```bash
|
||||
rsync -avz --delete rsync://rsync.osuosl.org/jenkins/ /var/www/jenkins
|
||||
```
|
||||
|
||||
4. Install dependencies:
|
||||
|
||||
```bash
|
||||
yum -y install make gcc automake autoconf python3-devel git
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
5. Setup mirrors json:
|
||||
|
||||
> Set your mirror url
|
||||
|
||||
```
|
||||
# mirrors.json
|
||||
{
|
||||
"localhost": "http://localhost/jenkins/"
|
||||
}
|
||||
```
|
||||
|
||||
6. Run the following python code:
|
||||
|
||||
```bash
|
||||
python3 generator.py
|
||||
cp localhost/update-center.json /var/www/jenkins/
|
||||
```
|
||||
|
||||
1. Put `update-center.crt` into `${JENKINS_HOME}/update-center-rootCAs` folder.
|
||||
2. Go to `Jenkins → Manage Jenkins → Manage Plugins → Advanced → Update Site` and submit URL to your `update-center.json`.
|
||||
|
||||
|
72
speed-test.sh
Normal file
72
speed-test.sh
Normal file
@ -0,0 +1,72 @@
|
||||
#!/bin/env bash
|
||||
#
|
||||
# lework
|
||||
# Jenkins mirror update center speed test.
|
||||
|
||||
|
||||
######################################################################################################
|
||||
# environment configuration
|
||||
######################################################################################################
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
BLUE='\033[0;36m'
|
||||
PLAIN='\033[0m'
|
||||
|
||||
image_name="library/centos"
|
||||
image_tag="latest"
|
||||
|
||||
declare -A mirrors
|
||||
mirrors=(
|
||||
[tencent]="https://mirrors.cloud.tencent.com/jenkins/"
|
||||
[huawei]="https://mirrors.huaweicloud.com/jenkins/"
|
||||
[tsinghua]="https://mirrors.tuna.tsinghua.edu.cn/jenkins/"
|
||||
[ustc]="https://mirrors.ustc.edu.cn/jenkins/"
|
||||
[bit]="http://mirror.bit.edu.cn/jenkins/"
|
||||
)
|
||||
|
||||
file="updates/current/plugin-versions.json"
|
||||
|
||||
######################################################################################################
|
||||
# function
|
||||
######################################################################################################
|
||||
|
||||
speed_test() {
|
||||
local output=$(LANG=C wget --header="$3" -4O /dev/null -T300 "$1" 2>&1)
|
||||
local speed=$(printf '%s' "$output" | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}')
|
||||
local ipaddress=$(printf '%s' "$output" | awk -F'|' '/Connecting to .*\|([^\|]+)\|/ {print $2}'| tail -1)
|
||||
local time=$(printf '%s' "$output" | awk -F= '/100% / {print $2}')
|
||||
local size=$(printf '%s' "$output" | awk '/Length:/ {s=$3} END {gsub(/\(|\)/,"",s); print s}')
|
||||
printf "${YELLOW}%-14s${GREEN}%-20s${BLUE}%-14s${PLAIN}%-20s${RED}%-14s${PLAIN}\n" "$2" "${ipaddress}" "${size}" "${time}" "${speed}"
|
||||
}
|
||||
|
||||
|
||||
######################################################################################################
|
||||
# main
|
||||
######################################################################################################
|
||||
|
||||
if [ ! -e '/usr/bin/wget' ]; then
|
||||
echo "Error: wget command not found. You must be install wget command at first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
clear
|
||||
echo -e "\n\nJenkins mirror update center speed test"
|
||||
|
||||
echo -e "\n[Mirror Site]"
|
||||
for mirror in ${!mirrors[*]}; do
|
||||
printf "${PLAIN}%-14s${GREEN}%-20s${PLAIN}\n" ${mirror} ": ${mirrors[$mirror]}"
|
||||
done
|
||||
|
||||
echo -e "\n[Test]"
|
||||
echo -e "Test File : ${YELLOW}${file}${PLAIN}\n"
|
||||
|
||||
printf "%-14s%-20s%-14s%-20s%-14s\n" "Site Name" "IPv4 address" "File Size" "Download Time" "Download Speed"
|
||||
for mirror in ${!mirrors[*]}; do
|
||||
speed_test "${mirrors[$mirror]}${file}" ${mirror}
|
||||
done
|
||||
|
||||
echo
|
Loading…
x
Reference in New Issue
Block a user