I use scripted pipeline. The method I use:
def String JenkinsUserID;
wrap([$class: 'BuildUser']) {
JenkinsUserID = env.BUILD_USER_ID;
}
println("DEBUG: found user '${JenkinsUserID}'.");
I'm embarrassed to admit that solution is more Internet-copy-paste than full comprehension (I don't understand the "wrap()" part, but it's needed), but it does do what I think you want.