How to get current login user in JIRA by Script Runner?

I want to get current login user in JIRA by Script Runner. Please provide me with the exact code

to get current log in user in JIRA.

1 answer

You can use this:

ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

Keep in mind that depending on the context, this method may return null - when a background job performs an operation, there will be no logged-in user.

If current login user is "xxx-yyy", then I want to return true, otherwise return false.

is the following code correct or not?

 

import com.atlassian.jira.component.ComponentAccessor

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

if (currentUser == "xxx-yyy" ) {

     return true

     } else {

     return false

 }

You need to compare with the user name:

return currentUser.name == "xxx-yyy"

I see. Thank you!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Monday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

464 views 0 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you