How to find personal repositories of deleted users

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

目的

Admins sometimes need to find personal repositories of users who are no longer with their company or who have been removed from Bitbucket Server.

ソリューション

This workaround will provide you as the Bitbucket Server admin access to the repositories of removed users and give you the ability to either delete them, or move them to a project of your choice.

Get a list of private repositories:

There are two SQL commands here that were created for MySql. The basic concept is the same if you are on Postgres, MS SQL Server, or Oracle but the actual SQL may need to be tweaked depending on your database type and the tool you are using to execute the SQL.

 

SELECT DETAILS, USER
FROM bitbucket.AO_BD73C3_REPOSITORY_AUDIT
Where USER IN 
 (
    SELECT USER_ID 
    FROM bitbucket.sta_normal_user 
    where deleted_timestamp 
    like '%'
    )
AND DETAILS like '%project%~%';

(info) Syntax for a Postgres database

Syntax for Postgres...

In case you are using a Postgres, make sure to quote the columns and the table names as in the example below, to force the usage of the uppercase for these values.

SELECT "DETAILS", "USER"
FROM "AO_BD73C3_REPOSITORY_AUDIT"
Where "USER" IN (
  SELECT user_id
  FROM sta_normal_user
  where deleted_timestamp is not null)
AND "DETAILS" like '%project%~%';

 

代替方法:

SELECT DETAILS, USER
FROM bitbucket.AO_BD73C3_REPOSITORY_AUDIT
Where USER IN 
 (
    SELECT USER_ID 
    FROM bitbucket.sta_normal_user 
    )
AND DETAILS like '%project%~%';

 

 

These SQL queries assume that the name of your database is "bitbucket". You will need to update the two FROM statements and replace bitbucket with the actual name of your database, and most DB types are case sensitive.

In both of the SQL statements the result will give you the username (prefixed with the ~) and the name of the repository.

With this information you can do the following:

Prior to Stash/Bitbucket Server 3.9:

  1. Login to Bitbucket as an admin
  2. If you want to create a graveyard project create it now
  3. Modify the address line to something like http://<BITBUCKET_SERVER>:7990/users/<USER_NAME_FROM_SQL>. User name is all lower case and do not include the "~". 
    Example: http://localhost:7990/users/bob
  4. You will be given a list of all that users repositories (even if the user has been deleted)
  5. Click on the repository and then click Properties (gear icon under the project options)
  6. You now have the option to delete or move the repository to a public or private project.

From Stash/Bitbucket Server 3.9 onwards:

  1. Login to Bitbucket as an admin
  2. If you want to create a graveyard project create it now
  3. Access each repository found with the query directly, modifying the address line to something like http://<BITBUCKET_SERVER>:7990/projects/~<USER_NAME_FROM_SQL>/repos/<REPOSITORY_NAME>/browse
    Example: http://localhost:7990/projects/~BOB/repos/repository1/browse
  4. You'll access the repository settings page, which will give you the options to either move or delete the repository.

 

In addition, there's a feature suggestion for allowing System Administrators to easily view orphaned repositories, left by deleted users. You may check this at BSERV-7265 - Getting issue details... STATUS - feel free to vote and add any comments to it, as well as adding yourself as a watcher so you can track its progress directly. You may refer to the Implementation of New Features Policy.

最終更新日 2016 年 7 月 8 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.