我可以在 preUpdate 中获取当前用户吗(atlassian bitbucket 插件)

May I get the current user in preUpdate (the atlassian bitbucket plugin)

根据 bitbucket 服务器参考 https://docs.atlassian.com/bitbucket-server/javadoc/5.3.0/spi/reference/com/atlassian/bitbucket/hook/repository/PreRepositoryHook.html

函数中

public RepositoryHookResult preUpdate(PreRepositoryHookContext context, RepositoryHookRequest request)

如何获取当前用户,或者谁在推送代码?不是提交的作者。

看这个例子https://github.com/tomasbjerre/simple-bitbucket-commit-checker/blob/master/src/main/java/se/bjurr/sbcc/SbccPreReceiveRepositoryHook.java

您需要传递给您的钩子 AuthenticationContext 对象并使用 getCurrentUser() 方法