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

This widget could not be displayed.

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
Posted yesterday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

62 views 0 1
Join discussion

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