How can I checkout all the git bitbucket repositories for a team using a bash script?
There are other questions for this topic however the bitbucket api mentioned in those answers does not exist anymore.
How can I checkout all the git bitbucket repositories for a team using a bash script?
There are other questions for this topic however the bitbucket api mentioned in those answers does not exist anymore.
The following script is working well to download all repositories from Bitbucket.
UserName not email
Create App-password from Bitbucket
Run the script by sh script.sh
#!/bin/bash
user=username:password
curl -u $user 'https://api.bitbucket.org/2.0/user/permissions/teams?pagelen=100' > teams.json
jq -r '.values[] | .team.username' teams.json > teams.txt
for team in `cat teams.txt`
do
echo $team
rm -rf "${team}"
mkdir "${team}"
cd "${team}"
url="https://api.bitbucket.org/2.0/repositories/${team}?pagelen=100"
echo $url
curl -u $user $url > repoinfo.json
jq -r '.values[] | .links.clone[0].href' repoinfo.json > repos.txt
for repo in `cat repos.txt`
do
echo "Cloning" $repo
git clone $repo
done
cd ..
done
I made a simple script available here: https://github.com/mimo84/cloner It works similarly to the answer from Marcelo, however it uses the api on bitbucket to fetch them. It has jq as dependency as well.