Skip to content

Instantly share code, notes, and snippets.

@larsar
Created October 4, 2016 06:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsar/72916ba18b269a672878e343dd35ed16 to your computer and use it in GitHub Desktop.
Save larsar/72916ba18b269a672878e343dd35ed16 to your computer and use it in GitHub Desktop.
Simple script for retrieving all rep URLs from Bitbucket Server
#!/usr/bin/env bash
URL="https://<HOST>/rest/api/1.0/projects"
>&2 printf "Enter Bitbucket Server credentials\n"
>&2 printf "Username: "
read username
>&2 printf "Password: "
read -s password
>&2 printf "\n\nFetching all repo urls. Please wait...\n"
curl -s -u $username:$password $URL?limit=1000 | json_pp
KEYS=`curl -s -u $username:$password $URL?limit=1000 | json_pp | grep key | cut -d \" -f 4`
for k in $KEYS; do
>&2 printf "Fetching repo urls for: $k\n"
printf "\nProject: $k\n"
curl -s -u "$username:$password" "$URL/$k/repos?limit=1000" | json_pp | grep ssh | grep href | cut -d \" -f 4
done
>&2 printf "Done\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment