How to find which repositories are actively being used
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
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.
*Fisheye および Crucible は除く
要約
It's important for some teams to be able to report on which repositories in their system are actively being used for the purposes of archiving or removing old repositories that are no longer in use.
環境
Bitbucket Server and Bitbucket Data Center.
ソリューション
While there's no kind of innate logging mechanism that accomplishes this request, it's possible to use the access logs in order to determine the number of requests made to a given repository.
- For example, the following bash script takes a given access log list (
$FILESTOSCAN
) and then outputs anygit-upload-pack
operations found in the logs, and then groups them by the repository that the request was made against and outputs the 20 most-accessed repositories for the logs provided for HTTP and SSH independently.
FILESTOSCAN="atlassian-bitbucket-access*.log"
echo "Number of Clones per Repository"
echo "HTTP(s) clones:"
grep -h "git-upload-pack" $FILESTOSCAN | grep ", clone" | grep -v "SSH" | awk -F '|' '{ print $6 }' | awk -F ' ' '{ print $2 }' | awk -F '/' '{ print $3"/"$4 }' | sed "s/'//" | sort | uniq -c | sort -n -r | awk '{printf "%'\''d - %s\n", $1, $2 }' > clone_count.rpt
head -20 clone_count.rpt
echo "SSH Clones:"
grep -h "git-upload-pack" $FILESTOSCAN | grep ", clone" | grep "SSH" | awk -F '|' '{ print $6 }' | awk -F ' ' '{ print $4 }' | awk -F '/' '{ print $2"/"$3 }' | sed "s/'//" | sort | uniq -c | sort -n -r | awk '{printf "%'\''d - %s\n", $1, $2 }' > clone_count.rpt
head -20 clone_count.rpt
The above script is provided on a best-effort basis, and Atlassian Support is unable to directly support this script or any customizations made to it to achieve your team's business needs.