return values for python in script runner

James Kelsall April 27, 2012

I am trying to create python scripts in script-runner but I am unable to figure out how to return values to the UI or to a log file so I can validate that my script is functioning as intended. Here is a very basic example script which which works for both groovy and python, but returns no information in python.:

Groovy:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue

def cmgr = ComponentManager.getInstance()
def issue = cmgr.getIssueManager().getIssueObject("PROJ-431")
  
return issue.key

Python:

from com.atlassian.jira import ComponentManager
import com.atlassian.jira.issue.Issue

cmgr = ComponentManager.getInstance()
issue = cmgr.getIssueManager().getIssueObject("PROJ-431")

print issue.key

Can someone point me in the right direction to get output from the python interpretor, either through log4j, which I am unable to load in the python interpretor or just as a return value in script-runner UI?

1 answer

1 accepted

1 vote
Answer accepted
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.
April 27, 2012

"print" will print to catalina.out.

> either through log4j, which I am unable to load in the python interpretor

What have you tried? I don't see why that wouldn't work.

To get the UI to display the return value you just need to "return" it, but that's not very flexible, you're better off with log4j.

James Kelsall May 9, 2012

Thanks, I think this was just an issue with learning curve :) Attempting to "return" a value in scriptrunner causes an error stating

SyntaxError: 'return' outside function in <script> at line number 7 at column number 0

I have managed to get log4j working, I was just importing it wrong.

Thanks!

Suggest an answer

Log in or Sign up to answer