Skip to content

Instantly share code, notes, and snippets.

@zhilyaev
Last active October 31, 2024 22:26
Show Gist options
  • Select an option

  • Save zhilyaev/5ec431ae9928b94c063d6a574a69b111 to your computer and use it in GitHub Desktop.

Select an option

Save zhilyaev/5ec431ae9928b94c063d6a574a69b111 to your computer and use it in GitHub Desktop.
gitlab-cloner.sh
#!/usr/bin/env bash
HOST_API="gitlab.com"
TOKEN="<token>"
fullPath="<path>"
q="{group (fullPath: \"$fullPath\") {projects(includeSubgroups: true) {nodes {sshUrlToRepo}}}}"
# brew install httpie
repos=`https -A bearer -a $TOKEN -b https://$HOST_API/api/graphql query="$q" \
| jq ".data.group.projects.nodes.[].sshUrlToRepo" | tr -d \"`
for repo in $repos; do
dir=$(echo $repo | awk -F ":" '{print substr($2, 1, length($2)-4)}')
mkdir -p $dir
git clone --depth 1 $repo $dir
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment