In ScriptRunner, I am using the line
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getUser()
which works just fine, but is flagged as deprecated. When I use the suggested replacement
def currentUser = JiraAuthenticationContext.getLoggedInUser()
the code is no longer flagged so it should work. However when actually executing the code, I get a strange error message:
2016-06-14 08:44:28,651 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2016-06-14 08:44:28,651 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: DM-4391, actionId: 1, file: <inline script> groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.security.JiraAuthenticationContext.getLoggedInUser() is applicable for argument types: () values: [] at Script18.run(Script18.groovy:22)
The JIRA version is 7.1.2, the ScriptRunner version is 4.3.1 (latest). The function JiraAuthenticationContext.getLoggedInUser()
belongs to the JIRA 7 API so it should be available to ScriptRunner. Also all interfaces are included:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.UpdateIssueRequest
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.security.JiraAuthenticationContext
def currentUser = JiraAuthenticationContext.getLoggedInUser()
I have no idea why this line fails. Please advise.
Are you trying ,
ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() ??
or
JiraAuthenticationContext.getLoggedInUser() ??
I was using the latter, but I now see the error.... for some reason I thought it was a static function, but it is actually not.
I am now using ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() which works.
Thanks a lot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am still confused why the ScriptRunner did not flag the original code as illegal though.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It seems to not be checking whether methods are called statically. But:
> the code is no longer flagged so it should work
this is a wrong inference. It just means (or it should mean) that the methods/properties exist and are of the correct type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.