Skip to content

Instantly share code, notes, and snippets.

@eeichinger
Last active March 26, 2024 20:57
Show Gist options
  • Save eeichinger/babbdf99d8fe21fef8634d56f29defba to your computer and use it in GitHub Desktop.
Save eeichinger/babbdf99d8fe21fef8634d56f29defba to your computer and use it in GitHub Desktop.
script to clone all repositories in a bitbucket server (aka stash) project
# 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
# 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://bitbucket.example.com/rest/api/1.0/projects/$PROJECTNAME/repos/ \
| jq -r '.values[].links.clone[] | select(.name=="ssh") | .href' \
| xargs -I {} echo "git clone '{}'" > clone_repos.sh
@Jenism
Copy link

Jenism commented Dec 2, 2021

@sreddy31 mentioned wrong person :D typo probably, should have mentioned @jensim not me

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