Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How to get current user in jira application?

I need to get current user in Jira.but i tried few ways but didn't get a solution.

4 answers

1 accepted

5 votes
Answer accepted
Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 11, 2018 • edited

Hello @Ramesh Lakshmanasamy

Did you mean get user in code of some plugins like Scriptrunner?

If you do, you can use

import com.atlassian.jira.component.ComponentAccessor
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

If you write jira plugin
you need to import it directly 

@ComponentImport JiraAuthenticationContext jiraAuthenticationContext

@Mark MarkovI tried above solution but getting null.

Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 11, 2018

Where are you tryin to get current user?

inside class which has contain my businesslogic

Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 11, 2018

where you run your class, if you run it in another thread, there are no authentication context so user is null. So you'll need to pass the user as parameter.

Can you provide example of your code?

Does anyone know how to get this using Scriptrunner for Jira Cloud?

I found 'user' does this so that you can use user.accountId to compare against, but it doesn't seem to work in all contexts like post functions.

Hi

How can we get " company name" value of current logged user of jira by using script

company.png

Thanks @Mark Markov it's working fine.

How to get the user in a Jira Service that extended from AbstractService and running from Service Scheduler/Cron?

 

ComponentAssessor.getJiraAuthenticationContext().getLoggedInUser()


always return null.

just paste this code to the console.

btw this script will just let you know that you are logged in :D

 

import com.atlassian.jira.component.ComponentAccessor

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

return user

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events