Hi,
I wrote the below groovy hook script and pasted in the script window.
package com.atlassian.bitbucket.server.examples;
import com.atlassian.bitbucket.hook.repository.PostRepositoryHook;
import com.atlassian.bitbucket.hook.repository.PostRepositoryHookContext;
import com.atlassian.bitbucket.hook.repository.RepositoryPushHookRequest;
import com.atlassian.bitbucket.hook.repository.SynchronousPreferred;
import com.atlassian.bitbucket.repository.RefChangeType;
import org.apache.log4j.Logger
import static org.apache.log4j.Level.DEBUG
import javax.annotation.Nonnull;
/**
* Hook that writes a warning to the git client when it detects a push to the master branch
*/
@SynchronousPreferred(asyncSupported = false)
public class PushToMasterWarnHook implements PostRepositoryHook<RepositoryPushHookRequest> {
private static final Logger log = Logger.getLogger(PushToMasterWarnHook.class);
@Override
public void postUpdate(@Nonnull PostRepositoryHookContext context,
@Nonnull RepositoryPushHookRequest request) {
System.out.println("triggered");
log.error("Log a message here");
}
}
There are no logs showing up in the log file and seems this is not executed at all after a push. I'm confused about the atlassian-plugin.xml as the above script was pasted in the scritps window, how to update this xml if needs to be updated at all?
Post Hooks > Custom script hook
Any suggestion is welcomed.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.