How to clone all projects of a group at once in GitLab?

后端 未结 15 1483
[愿得一人]
[愿得一人] 2020-12-23 02:02

In my GitLab repository, I have a group with 20 projects. I want to clone all projects at once. Is that possible?

15条回答
  •  情话喂你
    2020-12-23 02:48

    Here's an example in Python 3:

    from urllib.request import urlopen
    import json
    import subprocess, shlex
    
    allProjects     = urlopen("http://[yourServer:port]/api/v4/projects?private_token=[yourPrivateTokenFromUserProfile]&per_page=100000")
    allProjectsDict = json.loads(allProjects.read().decode())
    for thisProject in allProjectsDict: 
        try:
            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))
    

提交回复
热议问题