from urllib.request import urlopen
import json
import subprocess, shlex
allProjects = urlopen("https://{your gitlib host}/api/v4/groups/{you group name}/projects?private_token={your git private token}&per_page=100000")
allProjectsDict = json.loads(allProjects.read().decode())
for thisProject in allProjectsDict:
try:
thisProjectURL = thisProject['http_url_to_repo']
# ssh 使用 thisProjectURL = thisProject['ssh_url_to_repo']
command = shlex.split('git clone %s' % thisProjectURL)
resultCode = subprocess.Popen(command)
except Exception as e:
print("Error on %s: %s" % (thisProjectURL, e.strerror))
#新建python执行文件 gitBatchClone.py 内容为上述内容
#使用 python3 ./gitBatchClone.py运行
标签:git,克隆,批量,thisProject,private,subprocess,thisProjectURL,import From: https://www.cnblogs.com/zhanghengscnc/p/16769372.html