2

我刚刚在 gitblit 安装的 groovy 文件夹中编辑了 blockpush.groovy 脚本。我只是“返回错误”;为了检查脚本是否被调用。另外,在测试脚本中,日志文件中没有写入任何内容

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
        }
    }
4

1 回答 1

0

您需要配置您的存储库以使用 blockpush 挂钩脚本。

于 2015-12-14T14:32:36.337 回答