Created
May 21, 2019 00:31
-
-
Save seesleestak/00b8af84c874462cb2ca87ea59fad26b to your computer and use it in GitHub Desktop.
Bash script to clone all team repos from Bitbucket API
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 | |
USER="username" | |
PASS="password" | |
TEAM_NAME="teamName" | |
# Getting 10 pages of Bitbucket API response | |
for i in {1..10}; do | |
curl --user $USER:$PASS "https://api.bitbucket.org/2.0/repositories/$TEAM_NAME?page=$i" >> /tmp/repos | |
done | |
cat /tmp/repos | \ | |
perl -nle'print $& while m{"'"href"'"\s*:\s*"\K([^"]*)}g' | \ | |
grep "git@" | \ | |
xargs -L1 git clone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment