Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Script to find the logged in user in Jira 6

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

1 answer

0 votes
Elifcan Cakmak Community Leader Dec 31, 2018

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

Elifcan Cakmak Community Leader Jan 01, 2019

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:

https://docs.atlassian.com/software/jira/docs/api/6.4.9/com/atlassian/jira/security/JiraAuthenticationContext.html

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  

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

ThinkTilt is joining the Atlassian Family!

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...

430 views 19 23
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you