Сreate a comment on behalf of the system user

I created a plugin that adds comments to the pool request when it is created. This comment is created on behalf of the user who created the pool request .

Can I specify an account from which to create these comments?

1 Like

You can use SecurityService.impersonating( ... )

Cheers - Ulrich

1 Like

Yeap, already find this code. Working in Bitbucket 4.11.1

ApplicationUser user = userService.getUserBySlug("username");

securityService.impersonating(user, "reason").call(new Operation<Object, RuntimeException>() {
    public Object perform() throws RuntimeException {
        //you code
        return null;