Hi ,
The following script works fine in Jira 7.
final def authCtxInternal = com.atlassian.jira.component.ComponentAccessor.getJiraAuthenticationContext()
def logIn = { com.atlassian.jira.user.ApplicationUser u ->
try {
//Jira 7
authCtxInternal.setLoggedInUser(u)
} catch (Exception ignore) {
// Jira 6
//noinspection GroovyAssignabilityCheck
authCtxInternal.setLoggedInUser(u.getDirectoryUser())
}
}
But in Jira 6 its throwing error:
javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: CreateIssue$__clinit__closure1_closure5.call() is applicable for argument types: (com.atlassian.jira.crowd.embedded.ofbiz.OfBizUser) values: [a-4951:3] Possible solutions: any(), any(), doCall(com.atlassian.jira.user.ApplicationUser), each(groovy.lang.Closure), any(groovy.lang.Closure), each(groovy.lang.Closure)
I tried to use the code in Catch part in try for jira 6 but no luck.
Can anybody help me with this.
Thanks
Shilpa
Hello,
Do you want to get the name of the logged in user? Because the script you shared is using setLoggedInUser method and it does something different. Could you try it like this?
import
com.atlassian.jira.security.JiraAuthenticationContext;
def authenticationContext = ComponentAccessor.getJiraAuthenticationContext()
def user = authenticationContext.getLoggedInUser()
return user
Regards,
Elifcan
Hi Elifcan,
I want to set the logged in user to this: final def authCtxInternal = com.atlassian.jira.component.ComponentAccessor.getJiraAuthenticationContext().
This line: authCtxInternal.setLoggedInUser(u) is not working in Jira 6 whereas works fine in jira 7.
Thanks
Shilpa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I don't understand what you mean by:
I want to set the logged in user to this: final def authCtxInternal = com.atlassian.jira.component.ComponentAccessor.getJiraAuthenticationContext().
This is a line that imports and defines the authentication context on your code.
Anyways, setLoggedInUser is a valid method as far as I can see for Jira version 6. You can check on the docs:
You can use it with application user:
https://docs.atlassian.com/software/jira/docs/api/6.4.9/com/atlassian/jira/user/ApplicationUser.html
Regards,
Elifcan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Elfican,
I understand that setLoggedInUser is valid in both Jira 7 & 6 but the variable that you set is what throwing error.
def logIn = { com.atlassian.jira.user.ApplicationUser u ->
authCtxInternal.setLoggedInUser(u)
The above line is not working in Jira 6.
Thanks
Shilpa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.