Created
June 11, 2019 09:41
-
-
Save thomaspoignant/689a3daa7759c10b4989538d5338d01b to your computer and use it in GitHub Desktop.
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 | |
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