Query to retrieve Linked Repositories which aren't being used in any plans

Still need help?

The Atlassian Community is here for you.

Ask the community

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

The steps outlined on this article are provided AS-IS. This means we've had reports of them working for some customers — under certain circumstances — yet are not officially supported, nor can we guarantee they'll work for your specific scenario.

You may follow through and validate them on your own non-prod environments prior to production or fall back to supported alternatives if they don't work out.

We also invite you to reach out to our Community for matters that fall beyond Atlassian's scope of support!

Summary

This SQL query will retrieve linked repositories (global ones) that aren't used in any plans (no plans listed under the Usage tab).

Environment

This was tested on Microsoft SQL Server 2019

Solution

MS SQL Server
select VL.NAME,
       VL.VCS_LOCATION_ID,
       CONCAT('<BAMBOO_BASE_URL>/admin/editLinkedRepository.action?repositoryId=',VL.VCS_LOCATION_ID) AS EDIT_URL
from VCS_LOCATION VL
where VL.VCS_LOCATION_ID NOT IN
      (
          select VL.PARENT_ID
          from VCS_LOCATION VL
              JOIN PLAN_VCS_LOCATION PVL on VL.VCS_LOCATION_ID = PVL.VCS_LOCATION_ID
      )
  AND VL.IS_GLOBAL = 1
  AND VL.MARKED_FOR_DELETION = 0
  AND VL.PARENT_ID IS NULL

For your convenience, if you replace <BAMBOO_BASE_URL> with your Bamboo's URL, the third column of the result (EDIT_URL) will contain a direct URL to the web page where you can edit the Linked Repo. If you export it to Excel, you can use the following formula to convert the URL to an Hyperlink. E.g:

=HYPERLINK(C2;C2)

If you use a different DBMS, the above query will need to be translated into your DBMS's syntax.




Last modified on Jan 20, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.