我刚刚在gitblit安装的groovy文件夹中编辑了blockpush.groovy脚本。我只需“返回false”,以检查脚本是否被调用。此外,在测试脚本中,日志文件中没有写入任何内容。
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我做错了什么?我正在吟诵,后来又在推

我没有注意到这段代码是重要的部分
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
}
}发布于 2015-12-14 14:32:36
您需要配置您的存储库以使用块钩子脚本。
https://stackoverflow.com/questions/34268871
复制相似问题