Re: How to get logged in username of Jenkins in parameter's Groovy script?

2020-06-11 Thread Giles
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.

On Thursday, 11 June 2020 00:19:51 UTC-4, Gajanan Mahajan wrote:
>
> 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/dbf629ea-4570-4b21-ace7-13d70f4b5b0bo%40googlegroups.com.


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

2020-06-10 Thread Gajanan Mahajan
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.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/ffcb606c-8ff4-4574-8b04-0e51a88cb201o%40googlegroups.com.