Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Post hook script not executing, no logs avaible

Istvan Bereti
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 22, 2019

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

  • Atlassian Bitbucket v5.16.0

Any suggestion is welcomed.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events