I just edited the blockpush.groovy script in the groovy folder of the gitblit installation. I simply "return false;" in order to check if the script gets called. Also, in the test script, there is nothing written in the log file
Indicate we have started the script
logger.info("blockpush hook triggered by ${user.username} for ${repository.name}: checking ${commands.size} commands")
/*
* Example rejection of pushes to the master branch of example.git
*/
def file1 = new File('C:\\workspace\\test.txt')
file1.write 'Working with files the Groovy way is easy.\n'
return false
What am I doing wrong? I am commiting and afterwards pushing
I was not paying attention that this code was the important part
for (ReceiveCommand command : commands) {
def updatedRef = command.refName
if (updatedRef.equals('refs/heads/master')) {
// to reject a command set it's result to anything other than Result.NOT_ATTEMPTED
command.setResult(Result.REJECTED_OTHER_REASON, "You are not permitted to write to ${repository.name}:${updatedRef}")
blocked = true
}
}
You need to configure your repository to use the blockpush hook script.