It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

Hisamitsu Koga Aug 17, 2016

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

4 votes
Petar Petrov Aug 17, 2016

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.

Hisamitsu Koga Aug 17, 2016

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

 }

Petar Petrov Aug 17, 2016

You need to compare with the user name:

return currentUser.name == "xxx-yyy"
Hisamitsu Koga Aug 17, 2016

I see. Thank you!

Markus Pöhler Apr 29, 2019

@Petar Petrov what is the correct value for the comparison of the userName? I always get FALSE although I use the current logged in users Username with your sample code.... 

How to debug anything here? 

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

774 views 7 0
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you