Skip to content

Instantly share code, notes, and snippets.

@seesleestak
Created May 21, 2019 00:31
Show Gist options
  • Save seesleestak/00b8af84c874462cb2ca87ea59fad26b to your computer and use it in GitHub Desktop.
Save seesleestak/00b8af84c874462cb2ca87ea59fad26b to your computer and use it in GitHub Desktop.
Bash script to clone all team repos from Bitbucket API
#!/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