Skip to content

Instantly share code, notes, and snippets.

@XayOn
Created June 12, 2019 14:09
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 XayOn/f9a6872591489197e72aeed33db51e00 to your computer and use it in GitHub Desktop.
Save XayOn/f9a6872591489197e72aeed33db51e00 to your computer and use it in GitHub Desktop.
Clone all bitbucket repositories using ssh for a specific organization
# Usage $0: <org_name> <user> <password>
shopt -s lastpipe; set +m;
print_elements(){
curr=$(http get $1 -a "$2:$3")
jq -r '.values[].links.clone[] | select(.name == "ssh")|.href' <<< $curr
jq -r .next <<< $curr|read next_url
[[ $next_url != "null" ]] && print_elements $next_url $2 $3
}
while read repo; do git clone $repo; done < <(print_elements "https://api.bitbucket.org/2.0/repositories/$3/" $1 $2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment