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:
Community moderators have prevented the ability to post new answers.
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)
}
}
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
See the second answer in this post. Can you change the "Actor" field as shown?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Hamid Gull welcome on the community. Can you share more details? Can you share how your automation is configured?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.