Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
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

ScriptRunner Add-on user doesn't execute the script

I'm trying to have a script run as the JIRA ScriptRunner user for the "issue updated" event.

However, it will only ever execute as the user initiating, not the ScriptRunner user. I need the ScriptRunner user to execute this script so that I can do a PUT request into a field not visible on the screen.

I first check to see if we're executing as the "ScriptRunner for Jira" for JIRA user and it is not, as can be seen from the logs where I'm logging the "user" variable inside the script. 

image.png

image.png

Any ideas on how to make the ScriptRunner Add-on user run scripts instead of the Initiating user?

3 answers

1 accepted

0 votes
Answer accepted

Thanks to everyone who got back to me so promptly!

 

Turns out this was an error on my part. I have written a custom "jira_request" method but was using an older version of the method where I hadn't implemented QueryStrings for PUT requests. 

 

I am still seeing the user in the payload as my user, but the PUT request goes through so I'm not complaining! I actually want to add a catch to stop the script executing if it's not a human user initiating so it works as an advantage to me.

 

The below logs and payload shows that the PUT request finally goes through with the overrideScreenSecurity QuerySting. However the accountId 5d42.. is my account

image (15).pngimage (16).png

 

Many thanks all,

This is resolved for me.

 

Best,

Mark

0 votes
Payne Community Leader May 05, 2021

I use the following in a ScriptRunner script in a Jira Server instance; hopefully it will work for you in the Cloud version.

ApplicationUser jiraAdminUser = ComponentAccessor.getUserManager().getUserByName("jiraadmin")
ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(jiraAdminUser)

HI Payne,

Unfortunately, this code will not work in ScriptRunner for Jira Cloud as Jira Cloud only provides the rest API's that ScriptRunner can use and does not have the same Java API's like the server version has.

Regards,

Kristian

Like Payne likes this

Hi @Mark O_Shea 

Thank you for the question.

The user variable will be logged in user which is here the user which is why you are seeing this. If you configure this as the Add on User, the code will run as this user and you can see this by clicking the "Green" tick in the history section, then to the Payload tab.

Hope this helps.

Thank you

Kind Regards

Kate

Suggest an answer

Log in or Sign up to answer
TAGS

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