You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.
Join groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
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.
This morning, Atlassian announced the acquisition of ThinkTilt , the maker of ProForma, a no-code/low code form builder with 700+ customers worldwide. ThinkTilt helps IT empower any team in their or...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.