Last updated Dec 14, 2017

Hosting events

Overview

Bitbucket Data Center provides events which can be used to hook into SCM hosting operations. Of particular interest for hosting are the push event and the pull event.

Using Bitbucket Data Center events you can respond to user operations which repository hooks cannot. You can also replicate the behavior of global hooks.

Example: using an event to replicate global hooks

MyBitbucketEventListener.java

1
2
package com.atlassian.bitbucket.example;

import com.atlassian.event.api.EventListener;

public class MyBitbucketEventListener 
{
    @EventListener
    public void mylistener(RepositoryPushEvent pushEvent) 
    {
        // call to your psuedo-hook with pushEvent.getRepository() 
	// and pushEvent.getRefChanges()
    }
}

Note: you won't be able to reject a push or write information back to the client using this method.

Some examples of where we use these events in Bitbucket Data Center:

  • In pull requests, to work out if we need to update a pull request based on a client's push.
  • In branch permissions, to work out if we can delete a branch permission (when the branch is deleted).

Responding to application events is detailed here.

Rate this page: