How to find projects/repositories which have configured a particular plugin/hook.

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





Purpose

As a Bitbucket Server administrator you may have need to locate all projects or repositories currently using a particular plugin/hook on your Bitbucket Server instance.

This will work only when a Hook has been configured explicitly for a Repository. Since inherited hooks are applied for all repositories inside a project, they will not show up in the result.


Solution

The easiest way to get this data is from the REST API.  Please see the rest endpoint /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/webhooks for more details.  You can use name: to search for jenkins in the examples below.

Web hooks after Bitbucket 5.4

To find all hooks for a url for a repository.  Replace '<SLUG>' with the SLUG name:

SELECT repo.name,
       webhooks."URL"
FROM   "AO_A0B856_WEBHOOK" as webhooks
       join REPOSITORY as repo
         ON cast(webhooks."SCOPE_ID" AS INT) = repo.id
WHERE  repo.name = '<SLUG>';


Repository hooks

  • For example, for the Jenkins Webhook Plugin you can run the following SQL query to get the names of all repositories that has the webhook enabled.


    SELECT NAME
    FROM   repository
           JOIN sta_repo_hook
             ON repository.id = sta_repo_hook.repository_id
    WHERE  sta_repo_hook.hook_key LIKE '%jenkins%' 
  • You can run the following SQL query to get the names of all projects that has the webhook enabled.

    SELECT NAME
    FROM   project
           JOIN sta_repo_hook
             ON project.id = sta_repo_hook.project_id
    WHERE  sta_repo_hook.hook_key LIKE '%jenkins%' 

    The above queries were tested against a PostgreSQL database and may need to be altered to match the syntax of your specific database version/vendor.


DescriptionSQL query to list all repositories and projects using a plugin
ProductBitbucket server

Last modified on Jul 26, 2021

Was this helpful?

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