Last active
May 29, 2020 03:24
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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