REST end point for Script runner

Gopinath Velayudhan November 9, 2015

Hi - we are looking to automatically add new options to our select list and we see that Script runner provides a default build in script to add option. i would like to to know if there is a way we can all the script using REST.

Thanks

Gopinath

 

2 answers

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.
November 10, 2015

Hi Gopinath...

I've been meaning to write this up for a while, thanks for prompting me to do it wink

https://scriptrunner.adaptavist.com/4.2.0.2-SNAPSHOT/jira/builtin-scripts.html#_executing_built_in_scripts_remotely

For background, I met Gopinath at Summit, and he explained that he wanted to run the built-in script which bulk updates custom field options programatically.

It's true that JIRA's rest api is woefully short in terms of the configuration stuff. If you're using JIRA server and have SR you can write your own rest endpoints to fill in the gaps to some extent. In this case I'd use the existing built-in script rather than rewriting the code for this, as you need to handle that some options may already exist etc.

I'd imagine since they want to use Script Runner to change the fields options, they're wondering if they can target ScriptRunner via REST to run arbitrary JAVA remotely.

I've added the docs for running scripts in the script console via rest: https://scriptrunner.adaptavist.com/4.2.0.2-SNAPSHOT/jira/builtin-scripts.html#_executing_script_console_scripts_remotely 

GabrielleJ
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.
November 10, 2015

All hail Sir Jamie!

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.
November 11, 2015

My knighthood is still in the post ;-)

Gopinath Velayudhan November 11, 2015

Thanks a bunch. you are the Best :)

Gopinath Velayudhan January 5, 2016

Hi Jamie - we had a major issue in our production jira instance yesterday and Jira kept becomming un-responsive after an hour. we send all the logs to Atlassian and They came back to us saying that Script running is causing this issue and they asked us to disable it. "Looking at the stack trace error you provided : 2016-01-04 03:39:01,821 http-bio-8443-exec-200 WARN e23475 210x21708x22 gy97z6 172.30.69.189 /secure/QuickCreateIssue.jspa [jira.groovy.jql.ScriptFunctionSearchIndexer] Script runner reindexing failed on ESG-34200 It looks like this issue is caused by the 3rd party plugin called Script Runner. " I also saw this message in the log "2016-01-04 05:45:18,534 http-bio-8443-exec-13 ERROR anonymous 345x11524x6 1nzg9ci 10.6.248.157 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [common.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: Cannot get property 'name' on null object java.lang.NullPointerException: Cannot get property 'name' on null object at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:57) at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:169) at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:44) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:293) something about plugins then it starts with errors like these below : 2016-01-04 05:45:38,865 http-bio-8443-exec-95 ERROR e20264 345x11684x12 4lb1xt 172.30.71.8 /rest/viewIssue/1/remoteIssueLink/render/61160 [viewissue.issuelink.rest.RemoteIssueLinkResource] Error occurred while generating final HTML for r emote issue link: java.lang.RuntimeException: java.io.IOException: Failed to load Confluence Page from remote server Caused by: java.io.IOException: Failed to load Confluence Page from remote server Caused by: com.atlassian.sal.api.net.R esponseException: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate) Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cip her suites are inappropriate) " I use Behaviour plugin a lot for option list manipulation. The plugin is associated to only 1 project and it is not linked to the jira project as mentioned in the first error "ESG-34200" i am not understanding why it is trying to re-index this ticket. Can you help us with this. we are kind of not stuck since we have script runner disabled. Thanks Gopi

Steven F Behnke
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 5, 2016

For the love of God ask a new question instead of spamming unrelated questions.

Gopinath Velayudhan January 5, 2016

Sure i will do that.

0 votes
GabrielleJ
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.
November 9, 2015

hmmm, you mean adding an option to a JIRA Custom Field Select List via JIRA API? That's NOT possible at all. Currently, JIRA does not expose the Custom Field Administration stuff in the JIRA APIs so it's not possible to configure it other than on the UI itself.

I'm not sure why you thought ScriptRunner can do this though. What "add option" are you talking about here? 

Steven F Behnke
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.
November 9, 2015

I'd imagine since they want to use Script Runner to change the fields options, they're wondering if they can target ScriptRunner via REST to run arbitrary JAVA remotely.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events