Skip to content

Instantly share code, notes, and snippets.

@Baccata
Last active July 1, 2016 12:40
Show Gist options
  • Save Baccata/19189c45fcb9988461b729d844fb0d6e to your computer and use it in GitHub Desktop.
Save Baccata/19189c45fcb9988461b729d844fb0d6e to your computer and use it in GitHub Desktop.
Cloning all the repos under a user or team from bitbucket
#!/bin/bash
#Script to get all repositories under a user or team from bitbucket
#Usage: cloneAllBitbucket [username] [user_or_team]
curl -u ${1} https://api.bitbucket.org/1.0/users/${2} \
| jsawk 'return this.repositories.map(function(item){return item.name;})' \
| jsawk -n 'out(this)' \
| sed -e 's/^"//' -e 's/"$//' > repos
for repo_name in `cat repos`
do
git clone ssh://[email protected]/${2}/$repo_name
done
#rm repos
@jpallari
Copy link

jpallari commented Jul 1, 2016

From ShellCheck:

$ shellcheck cloneAllBibucket.sh

Line 5:
curl -u ${1}  https://api.bitbucket.org/1.0/users/${2} \
        ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                  ^-- SC2086: Double quote to prevent globbing and word splitting.

Line 10:
for repo_name in `cat repos`
                 ^-- SC2013: To read lines rather than words, pipe/redirect to a 'while read' loop.
                 ^-- SC2006: Use $(..) instead of legacy `..`.

Line 12:
        git clone ssh://[email protected]/${2}/$repo_name
                                          ^-- SC2086: Double quote to prevent globbing and word splitting.
                                               ^-- SC2086: Double quote to prevent globbing and word splitting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment