Answers: <p>From the <a href="https://javadoc.jenkins-ci.org/hudson/model/User.html" rel="noreferrer">Java API documentation for <code>hudson.model.User</code></a>:</p>
  
  <blockquote>
    <p><code>String</code>  <code>getDisplayName()</code>
    Returns the user name.</p>
    
    <p><code>String</code>  <code>getFullName()</code>
    Gets the human readable name of this user.</p>
    
    <p><code>String</code>  <code>getId()</code></p>
  </blockquote>
  
  <p>It's not clear to me from your question what data you want (I think it's the user ID?), so I'm not sure which of these methods will get you that data (<code>getId()</code>?).  But in any case, you would call the method like:</p>
  
  <pre><code>User.current().getId()
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2020-06-12T08:20:18.417Z
Answers: Yes jayhendren, `getId()` is what I needed. Thanks a lot for help and most importantly pointing to documentation link.
Answers: Alpha
Answers: CC BY-SA 4.0
Answers: 2020-06-11T17:31:14.447Z
Answers: 2020-06-11T17:31:14.447Z
Answers: jayhendren
Body: <p>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</p>
  
  <p>Ex - User, that is displayed left to 'log out', could be - Bob Gill and username, used to login - could be - bob</p>
  
  <p>User can be retrieved using <code>User.current()</code>. Please tell me how to get username.</p>
  
  <p><strong>NOTE</strong> I don't need username in pipeline code. I need it in Groovy script of parameter.</p>
  
Tags: <jenkins><jenkins-pipeline>
Title: How to get logged in username of Jenkins in parameter's Groovy script?
UserDisplayName: Alpha
ThreadText: # How to get logged in username of Jenkins in parameter's Groovy script?
  
  (Asked by: username_0 on 2020-06-11)
  
  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.
  
  **Tags:** jenkins, jenkins-pipeline
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-06-11. Score: 5 | Accepted answer
  
  From the [Java API documentation for `hudson.model.User`](https://javadoc.jenkins-ci.org/hudson/model/User.html):
  
  > `String` `getDisplayName()`
  > Returns the user name.
  >
  > `String` `getFullName()`
  > Gets the human readable name of this user.
  >
  > `String` `getId()`
  
  It's not clear to me from your question what data you want (I think it's the user ID?), so I'm not sure which of these methods will get you that data (`getId()`?). But in any case, you would call the method like:
  
  ```
  User.current().getId()
  
  ```
  
  > **Comments:**
  > **username_0**: Yes username_1, `getId()` is what I needed. Thanks a lot for help and most importantly pointing to documentation link.  
  
  ---
  
  