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.
Any ideas on how to make the ScriptRunner Add-on user run scripts instead of the Initiating user?
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
Many thanks all,
This is resolved for me.
Best,
Mark
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Join PM Evangelist, Axel Sooriah, & Product Ops. Consultant & Advisor, Jenny Wanger, as they unpack the role of product ops and discuss key takeaways in Atlassian’s ‘The Product Ops Mission’ guide. They’ll answer your questions live on May 6 at 9:00am PT.
Register here ⬇️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.