return values for python in script runner

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

This widget could not be displayed.

"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.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

91 views 1 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you