Forked from eeichinger/generate_clone_all_bitbucket_repos.sh
Last active
August 15, 2018 08:02
-
-
Save raglin/cb7ddaf7bddccf26535091ac02fbc6a3 to your computer and use it in GitHub Desktop.
script to clone all repositories in a bitbucket server (aka stash) project
This file contains hidden or 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
| # this script uses syntax for bitbucket server. | |
| # For bitbucket cloud see https://confluence.atlassian.com/bitbucket/use-the-bitbucket-cloud-rest-apis-222724129.html | |
| # | |
| # Note: replace username, password and PROJECTNAME with your values | |
| USERNAME=xxxx | |
| PASSWORD=xxxx | |
| PROJECTNAME=xxxxx | |
| HOST=xxxxx | |
| # jq syntax helpful links: | |
| # - http://stackoverflow.com/questions/30601278/how-to-extract-keys-from-multiple-nested-arrays-using-jq | |
| # - http://stackoverflow.com/questions/18592173/select-objects-based-on-value-of-variable-in-object-using-jq | |
| curl -s -u $USERNAME:$PASSWORD https://$HOST/rest/api/1.0/projects/$PROJECTNAME/repos?limit=1000 \ | |
| | jq -r '.values[].links.clone[] | select(.name=="ssh") | .href' \ | |
| | xargs -n 1 git clone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment