Unable to run a groovy script as a service using script runner

RahulG
Contributor
January 11, 2016

Hello,

I am using Jira version 6.2.2, Script runner 3.0.16

I wrote a groovy script which performs the auto transition just like (https://scriptrunner.adaptavist.com/latest/jira/recipes/jelly-migration.html#_in_code) and trying to run this as a service. The script works well when I run it in the script console, but it is not working when I run it as service.  Below is the error message from the log file.

Error Messages: It seems that you have tried to perform a workflow operation (Inactive - Pending Closure) that is not valid for the current state of this issue (xxx-10101). The likely cause is that somebody has changed the issue recently, please look at the issue history for details.

I suspect that I need to make the Jira user in the script to authenticate first, if this is correct could anyone help me with the script for making a Jira user authenticate (login).

 

Thanks in advance,

Rahul.

 

7 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Royce Wong
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2016
To run as a script (that saved a a file) in JIRA serivce, you need to authenticate the user that's running the service:

def AuthContext=ComponentAccessor.getJiraAuthenticationContext()
AuthContext.setLoggedInUser(user)

Good thing is, you don't need to supply the user's password.
RahulG
Contributor
January 13, 2016

Thanks Royce, it worked for me.

0 votes
Juliani Schlickmann
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 14, 2019

Hey,

How can I know if my script ran? I created a service and pointed it to a .groovy script

https://community.atlassian.com/t5/Marketplace-Apps-questions/Groovy-Script-to-run-as-a-service/qaq-p/1030794

Thank you

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 11, 2016

Please post your full script. https://scriptrunner.adaptavist.com/latest/jira/recipes/jelly-migration.html#_in_code shows how to do the transition as any particular user.

0 votes
RahulG
Contributor
January 11, 2016

I am going to run my script as a service (https://scriptrunner.adaptavist.com/latest/jira/services.html) using Script Runner Add-On (Version 3.0.16).

0 votes
Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 11, 2016

Could you explain how your script is launched. Is it a postfunction or some plugin run a script?

0 votes
RahulG
Contributor
January 11, 2016

Hello Vasiliy, Thanks for your response I need to make the script user authenticate first by giving credentials like User Name and Password in the script to make the user login,so that he has necessary permissions to perform the tasks. Could you you please help me with a sample script which makes the user authentication first.

0 votes
Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 11, 2016

It seems that you have some permission trouble. Make sure that a users who use this script have respective rigth to do it.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events