Skip to content

Instantly share code, notes, and snippets.

@ashishmohite
Created September 3, 2018 06:27
Show Gist options
  • Save ashishmohite/757abf19f210e1f2c92b2c7aaa92d1f3 to your computer and use it in GitHub Desktop.
Save ashishmohite/757abf19f210e1f2c92b2c7aaa92d1f3 to your computer and use it in GitHub Desktop.
import json
import subprocess, shlex
private_token = "mytoken"
groups = requests.get("https://[host]/api/v3/groups/?private_token={}".format(private_token)).json()
for group in groups:
print("=============================")
print(group)
projects = requests.get("https://[host]/api/v3/groups/{}/projects?private_token={}".format(group["id"], private_token))
for project in projects.json():
projectURL = project['ssh_url_to_repo']
try:
command = shlex.split('git clone %s' % projectURL)
resultCode = subprocess.Popen(command)
except Exception as e:
print("Error on %s: %s" % (projectURL, e.__str__()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment