Created
October 4, 2016 06:54
-
-
Save larsar/72916ba18b269a672878e343dd35ed16 to your computer and use it in GitHub Desktop.
Simple script for retrieving all rep URLs from Bitbucket Server
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
#!/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