python clone gitlabを使用して、すべての可視項目があります。

3216 ワード

import json
import shlex
import subprocess
import time
from urllib.request import urlopen

allProjects = urlopen("http://ip:port/api/v4/projects?membership=true&private_token=aaaaaaaaaaaaa")
allProjectsDict = json.loads(allProjects.read().decode())
for thisProject in allProjectsDict:
    try:
        thisProjectURL = thisProject['ssh_url_to_repo']
        name_with_namespace = thisProject['path_with_namespace']
        command = shlex.split('git clone %s %s' % (thisProjectURL, 'G:/gitClone/'+name_with_namespace))
        resultCode = subprocess.Popen(command)
    except Exception as e:
        print("Error on %s: %s" % (thisProjectURL, e.strerror))
    time.sleep(5)
また、urlopenのアプリはapiから来ていますので、適宜交換してもいいです。