Installed plugin enabled system-wide instead of per repository

plugin-sdk
bitbucket-server

#1

Hi,

I’ve written a BitBucket plugin that enforces a naming scheme for branches (a requirement from a team at my company) and validates a Jira project ID in the branch name through the use of Application Links. Once it’s installed on BitBucket, the enforcement works as expected however I’ve found that it’s enabled system-wide even if it’s disabled on the repo Hook’s page. This means even repositories that have it disabled and do not want to use it, have it enabled of them.

For example, Repo A might have it enabled and it’ll work just fine for them where as Repo B, has it disabled and yet the enforcement is still enabled for them.

The plugin enforces on branch creation from both pushes from local to remote repository and the BranchCreationEvent through the UI but the issue is only being seen specifically through the UI.

In the log file for BitBucket, I’m seeing the following errors related to my plugin but not sure what might be causing the issue exactly:

2018-03-15 17:22:21,662 WARN  [ThreadPoolAsyncTaskExecutor::Thread 86]  c.a.plugin.osgi.factory.OsgiPlugin Ignoring the bean container that was just created for plugin com.atlassian.branchenforce.branch-enforce-plugin.  The plugin is in an invalid state, DISABLED, that doesn't support a transition to enabled.  Most likely, it was disabled due to a timeout.
2018-03-15 17:22:26,570 WARN  [http-nio-7990-exec-3] xxxxx xxxxxx xxxxx xx.xx.x.xxx,x:x:x:x:x:x:x:x "GET /rest/plugins/1.0/installed-marketplace HTTP/1.0" com.atlassian.upm.pac.PacClientImpl Update check request may take longer because of the number of add-ons
2018-03-15 17:23:13,764 INFO  [http-nio-7990-exec-11] xxxxx xxxxxx xxxx xx.xx.x.xxx,x:x:x:x:x:x:x:x "POST /rest/branch-utils/latest/projects/SNB/repos/sandbox/branches HTTP/1.0" c.a.s.i.h.r.DefaultRepositoryHookService [SNB/sandbox[3]] hook 'legacy-ref-change-requested-event-hook' vetoed the branch-create request

The log entry suggests it’s in a disabled state and that I’m using a legacy method of calling the BranchCreationRequestedEvent, is this correct?

Could I be missing code that handles the enabling and disabling of the plugin?

BitBucket version: 5.3.2
Atlassian SDK: 6.3.4


#2

Bitbucket Server apps are always global. Depending on which modules you’re using - they can be filtered down to be repository specific though. In your case - make sure to look at https://developer.atlassian.com/server/bitbucket/reference/plugin-module-types/repository-hook-plugin-module/ since those are repository specific.