How to obtain a list of all projects and repositories from Bitbucket database
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Purpose
Whenever you have too many projects and too many repositories configured in the instance, having a better picture of how many of each you have can become challenging.
The purpose of this article is to help anybody that needs to retrieve a list of projects and repositories, along with personal repositories, directly from the database used by Bitbucket Server.
Advanced repository management available in Bitbucket Data Center 7.13
In 7.13, Bitbucket introduced Advanced repository management allowing you to more easily manage all of the repositories in your instance from the Repositories page in the Administration area.
Solution
- Connect to the database used by Bitbucket Server using the database vendor supplied tool or maybe using a client like DBVisualizer.
Run the following SQL query:
SELECT prj.name AS "Project / User Name" , prj.project_key AS "Project / User Key" , rep.name AS "Repository Name" , rep.slug AS "Repository Slug" FROM repository rep INNER JOIN project prj ON rep.project_id = prj.id ORDER BY prj.name, rep.name
Sample result:
Project / User Name Project / User Key Repository Name Repository Slug ------------------- ------------------ --------------- --------------- Project PROJ Temp1 temp1 Project Two PT GitHook githook ~internal1 ~INTERNAL1 PersonalRepo personalrepo
Where
- Project
Project One
has one repositories, namedTemp1
. - Project
Project Two
has one repository, namedGitHook
. - User
internal1
has a personal repository, namedPersonalRepo
.
- Project