Skip to content

Instantly share code, notes, and snippets.

@DessertArbiter
Last active May 29, 2020 03:24
Show Gist options
  • Save DessertArbiter/99bbf17290dcff0d2dec673449621926 to your computer and use it in GitHub Desktop.
Save DessertArbiter/99bbf17290dcff0d2dec673449621926 to your computer and use it in GitHub Desktop.
clone all gitlab projects under group over http, requires curl, jq, git, and trim
#!/bin/bash
# curl, jq, git, and trim are required
echo "This script clones all repos under the specified subgroups in any gitlab instance"
echo "for even more nested subgroups, you must use %2F instead of / because gitlab is weird"
echo "ex.: subgroup%2Fsubsubgroup%2Fsubsubsubgroup"
read -p "Enter gitlab instance url (include http(s)://): " gitlabInstance
read -p "Enter the group id: " groupId
echo "Enter subgroup id's, 1 per line (ctrl+d to stop): "
while read subgroupIdRead
do
subgroupIdArray+=( $subgroupIdRead )
done
for subgroupId in ${subgroupIdArray[@]}
do
for repo in $(curl "$gitlabInstance/api/v4/groups/$groupId%2F$subgroupId" | jq .projects[].http_url_to_repo | tr -d '"')
do
git clone $repo
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment