Using preRecieveHook to access files

Hi, I’m new here I’m using the SDK to develop a plugin for pre-recive-hook using the atlas-connect-bitbucket-plugin and atlas-connect-bitbucket-plugin-module

I’m trying to create an instance for commitService but when I do it like this:

public class myHook implements PreReceiveRepositoryHook {
    private final CommitService commitService;

    public myHook(CommitService commitService) {
        this.commitService = commitService;

    public boolean onReceive(RepositoryHookContext context, Collection<RefChange> refChanges, HookResponse hookResponse)


        return true;

the plugin disappears from the hooks list on my localhost server…

Is there another way to initialize the commitService?

Hi Hadar,

You are probably seeing some errors in the logs about “No Bean implementing CommitService found”?
The problem is that you are missing the @ComponentImport annotation in your constructor (com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport):

    public myHook(@ComponentImport CommitService commitService) {
        this.commitService = commitService;

That annotation tells the Spring scanner that the CommitService object needed to construct your class should be provided by Bitbucket. Without it the scanner will try to find a class in your plugin that is annotated with the @Component annotation and implements CommitService. No such class is found, thus it fails to initialise the hook in your plugin.

Let me know if this helps!

this works :),
actually in the meantime I found another solution using ComponentLocator like so:

CommitService commitService = ComponentLocator.getComponent(CommitService.class);

is there a good reason to use your solution in compared to this?