Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomaspoignant/689a3daa7759c10b4989538d5338d01b to your computer and use it in GitHub Desktop.
Save thomaspoignant/689a3daa7759c10b4989538d5338d01b to your computer and use it in GitHub Desktop.
#!/bin/bash
BITBUCKET_BASE_URL=https://bitbucket.xxxx.fr
CURL_RESULT=$(curl -u $USER:$PASSWORD $BITBUCKET_BASE_URL/rest/api/1.0/projects\?limit\=100 | jq -c .values)
FOLDERS=$(echo $CURL_RESULT | jq -r '.[]' | jq -r .key)
for KEY in $FOLDERS
do
mkdir $KEY
cd $KEY
REPO_IN_FOLDER=$(curl -u $USER:$PASSWORD $BITBUCKET_BASE_URL/rest/api/1.0/projects/$KEY/repos\?limit\=100 | jq -r .values[] | jq .links | jq -c '.clone[]' | jq -r .href | grep https)
for REPO in $REPO_IN_FOLDER
do
END_URL="$( echo "$REPO" | sed -e 's#^http://##; s#/score/$##' | cut -d "@" -f 2)"
CLONE_URL=https://$USER:$PASSWORD@$END_URL
git clone $CLONE_URL --depth 20
done
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment