Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira, Scriptrunner - getCurrentUser in Project Automation

Hamid Gull
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 20, 2021

I'm trying to send the currently logged-in user in a Post-Request to a REST-Endpoint when the issue is assigned. I set up a project automation with a ScriptRunner Script. According to several sources (see below) the following should do the magic.

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

This snippet works, but it's always my user, that is sent. Doesn't matter if I'm logged in or my colleague. What am I missing? The same problem occurs when I use the built-in field currentUser.

Sources:

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
juergen_mezger April 11, 2025

Hi there, there ist no solution from Atlassian, so here ist my Tip for Jira DataCenter
you can write a ScriptRunner Programm, wich uses the HttpSession and the Request Data to determine the "real" user

I have tested this in Chrome and Edge

(i wrote this in a helper Class in ScriptRunner so it is a static method. After you have the "real" user (not the automation actor) you can do your work for example write a comment with the

ComponentAccessor.getCommentManager()


Here is my code (maybe it helps)

public static String getActualuser()
{
def request = ComponentAccessor.getComponent(HttpContext)?.getRequest()
if (request) {
HttpSession httpSession = request.getSession()
def userid= httpSession.getAttribute('seraph_defaultauthenticator_user_id')
return(userid )
} else {
return(null)
}

}

 

SilkeS
Community Manager
Community Managers are Atlassian Team members who specifically run and moderate Atlassian communities. Feel free to say hello!
April 11, 2025

Hi @juergen_mezger ,

This topic has been locked because the thread has become a bit dated. If you’d like to keep the conversation going or have additional questions, we encourage you to start a new topic. You can read more about necro posting (“raising threads from the dead”) in our  Community Guidelines .

Thanks!

0 votes
Payne
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.
September 21, 2021

See the second answer in this post. Can you change the "Actor" field as shown?

0 votes
Martin Bayer _MoroSystems_ s_r_o__
Community Champion
September 20, 2021

Hi @Hamid Gull welcome on the community. Can you share more details? Can you share how your automation is configured?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events