Skip to content

Instantly share code, notes, and snippets.

@UnixSage
Last active January 22, 2024 17:13
Show Gist options
  • Save UnixSage/210c23e0c37e10685c4b0ded7e40be3a to your computer and use it in GitHub Desktop.
Save UnixSage/210c23e0c37e10685c4b0ded7e40be3a to your computer and use it in GitHub Desktop.
Simple Script to get a list of BitBucket repos for a given team
#!/bin/bash
USER="##USER_NAME_NOT_EMAIL##"
SECRET="##SECRET##"
TEAM="##TEAMNAME##"
CACHE="/tmp/repolist.$$"
REPOFILE="/tmp/repolist.txt"
URL="https://api.bitbucket.org/2.0/repositories/${TEAM}?pagelen=100"
rm ${REPOFILE}
while [ ! ${URL} == "null" ]
do
curl -q#u "${USER}:${SECRET}" "$URL" > ${CACHE}
jq -r '.values[].full_name' < ${CACHE} | sed 's~^.*/~~' >> ${REPOFILE}
URL=`jq -r .next ${CACHE}`
done
rm ${CACHE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment