How to get logged in username of Jenkins in parameter’s Groovy script?

In Jenkins parameter, I’m writing Groovy script and in that script I need to pass Jenkins logged in username NOT user. User and username, could be different

Ex – User, that is displayed left to ‘log out’, could be – Bob Gill and username, used to login – could be – bob

User can be retrieved using User.current(). Please tell me how to get username.

NOTE I don’t need username in pipeline code. I need it in Groovy script of parameter.

Go to Source
Author: TDHM