[Script Runner] Changing Language

Hi guys, I am working with the Script Runner Plugin in order to create subtasks automatically. 

To accomplish my goal, I inserted a post-function (Script workflow function) in the creation of the Issue. That is working pretty well. However, I discovered that I must create 104 tasks at the total. So, setup that creating one post function by one  would take too long and would not manageable. Then I decided to use a script that I found on the internet, that create tasks, in the same way. Would be easier to work with the script.

However, the script seems to be written in Ruby. 

Reading on the internet, I figured out that Script Runner Plugin is set by default to read Groovy.

Is Groovy the default language of Script Runner? If it is true, then how to change that to Ruby?


Thanks in advance,

Matheus Fernandes.

1 answer

Below the code that I am using:
# createSubtasks.jy
# Get the initial (parent) issue key (passed in)
# Get some of the parent's values (assignee, components, labels)
# Create new sub-tasks:
# 4 x Dev Task (issuetype.ID = 14)
# 1 x QA Task (issuetype.ID = 17)
# 1 x Documentation Task (issuetype.ID = 15)
# 1 x Infrastructure Task (issuetype.ID = 16)
# Issue is inherited.
# Sub-tasks inherit components from the parent issue
### from com.atlassian.jira.util import ImportUtils from com.atlassian.jira import ManagerFactory from com.atlassian.jira import ComponentManager from com.atlassian.jira.util import EasyList import java.util.ArrayList as ArrayList issueManager = ComponentManager.getInstance().getIssueManager() issueFactory = ComponentManager.getInstance().getIssueFactory() authenticationContext = ComponentManager.getInstance().getJiraAuthenticationContext() subTaskManager = ComponentManager.getInstance().getSubTaskManager(); def addSubTask(issueTypeId, subTaskName): log.debug("Adding subTask: " + subTaskName) issueObject = issueFactory.getIssue() issueObject.setProject(issue.getProject()) issueObject.setIssueTypeId(str(issueTypeId)) issueObject.setParentId(issue.getId()) issueObject.setSummary(subTaskName) issueObject.setAssignee(issue.getAssignee()) issueObject.setDescription(subTaskName) issueObject.setReporter(issue.getReporter()) subTask = issueManager.createIssue(authenticationContext.getUser(), issueObject) # issue.getGenericValue() gets a dump of the entire issue object log.debug("issue.getGenericValue(): " + str(issue.getGenericValue())) subTaskManager.createSubTaskIssueLink(issue.getGenericValue(), subTask, authenticationContext.getUser()) # Once all the subtasks have been created # Update search indexes ImportUtils.setIndexIssues(True); ComponentManager.getInstance().getIndexManager().reIndex(subTask) ImportUtils.setIndexIssues(False)
# Note: Jira v4.2.2 version requires an excplit flush.
# ManagerFactoryWARN.getCacheManager().flush(ManagerFactory.getCacheManager().ISSUE_CACHE, subTask);

# Add the subtasks to the User Story log.debug("Calling function addSubTask Adding Dev Task: Design Review") addSubTask(14,'Design Review') log.debug("Calling function addSubTask Adding Dev Task: Code Review") addSubTask(14,'Code Review') log.debug("Calling function addSubTask Adding Dev Task: Test Case Review") addSubTask(14,'Test Case Review') log.debug("Calling function addSubTask Adding Dev Task: Development Documentation Review") addSubTask(14,'Development Documentation Review') log.debug("Calling function addSubTask Adding QA Task: QA Documentation Review") addSubTask(17,'QA Documentation Review') log.debug("Calling function addSubTask Adding Documentation Task: Write Documentation") addSubTask(15,'Write Documentation') log.debug("Calling function addSubTask Adding Infrastructure Task: Infrastructure Task Placeholder") addSubTask(16,'Infrastructure Task Placeholder')

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,086 views 4 9
Read article

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