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

How can I get currentuser with scriptrunner in jira cloud?

Kedar Kanel August 20, 2024

I want to get the current user using scriptrunner in jira cloud. I want to add in currentuser name in the comment of an issue. But I couldnot figure out how to do so with scriptrunner in jira cloud. I did try

  • currentUser, 
  • executionUser.displayName
  • currentUser?.displayName
  • event.user.displayName

 

But didnot have any luck with them. 

Can someone please help?

3 answers

Suggest an answer

Log in or Sign up to answer
2 votes
Shawn Doyle - ReleaseTEAM
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 20, 2024

This is a 7 year old post, if my time math is correct, but you may give the solution here a try while waiting on Addaptivist 

https://community.atlassian.com/t5/Jira-questions/scriptrunner-cloud-currentuser/qaq-p/7910

2 votes
Dave Rosenlund _Trundl_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 20, 2024

Hi, @Kedar Kanel 👋 

 

I moved your post here, to App Central. This is a better place for this.

That said, you may get to a faster resolution by reaching out to the scriptrunner support team directly:

https://the-adaptavist-group-support.atlassian.net/servicedesk/customer/port

Best,

-dave

0 votes
Sean Chua _Adaptavist_
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.
August 27, 2024

@Kedar Kanel , @Shawn Doyle - ReleaseTEAM is absolutely right..

When you run the listener/script - use Current User. If you use SR add-on, then it will show as SR add-on.....

 

so try:

def response = get('/rest/api/3/myself')
.header('Content-Type', 'application/json')
.asObject(Map)
assert response.status == 200

def currentUsername = response.body.displayName

 then use ${currentUsername} in the comment.

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events