Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Updating a python script - Script Listener -

Elif Alverson June 21, 2016

Hello, 

I need to make some changes on a python script provided to me. This script creates subtasks for a specific issue type. I need one of these subtasks to be assigned to a specific user and 2 watchers will be added to it.

I am not familiar with the python script writing , so anyone is willing to help? Any help will be appreciated.

Thank you.

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
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.
June 21, 2016

This is groovy, not pyton. Here is modified script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.watchers.WatcherManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager

def parentIssue = event.issue
if (parentIssue.getIssueType().getName() != 'New User')
    return

def user = ComponentAccessor.getJiraAuthenticationContext().getUser().directoryUser
def summariesList = ["Subtask0",
                     "Subtask1",
                     "Subtask2 ",
                     " Subtask3",
                     " Subtask4",
                     " Subtask5",
                     " Subtask6",
                     " Subtask7"]
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()

WatcherManager watcherManager = ComponentAccessor.getWatcherManager();

//here we fill an aaray with all requared wathers
UserManager userManager = ComponentAccessor.getUserManager()
List<ApplicationUser> newWatchers = new ArrayList<>();
newWatchers.add(userManager.getUserByName("Sam user name"))
newWatchers.add(userManager.getUserByName("John user name"))
newWatchers.add(userManager.getUserByName("Jack user name"))

summariesList.each { subTaskSummary ->
    MutableIssue newSubTask = issueFactory.getIssue()
    newSubTask.setSummary(subTaskSummary)
    newSubTask.setParentObject(parentIssue)
    newSubTask.setPriorityId(constantManager.getPriorities().find {
        it.getName() == "Major"
    }?.id)

    newSubTask.setProjectObject(parentIssue.getProjectObject())
    newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{
        it.getName() == "Sub-task"
    }.id)
    // Add any other fields you want for the newly created sub task

    log.debug("New issue ${newSubTask}")
    Map<String,Object> newIssueParams = ["issue" : newSubTask] as Map<String,Object>
    issueManager.createIssueObject(user, newIssueParams)
    subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user)

    //here we add watchers for a subtask
    newWatchers.each {
        watcherManager.startWatching(it, newSubTask)
    }

    log.info "Issue with summary ${newSubTask.summary} created"
}
Elif Alverson June 21, 2016

Vasiliy, 

I have tried this script below however it does not work.

First : It stopped creating subtasks.

Since it does not add subtasks I cannot test the automated assignee for suntask 3 and the watchers. 

Thank you.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.watchers.WatcherManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager

def parentIssue = event.issue
if (parentIssue.getIssueType().getName() != 'New User')
return

def user = ComponentAccessor.getJiraAuthenticationContext().getUser().directoryUser
def summariesList = ["Subtask0",
"Subtask1",
"Subtask2 ",
" Subtask3",
" Subtask4",
" Subtask5",
" Subtask6",
" Subtask7"]
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()

WatcherManager watcherManager = ComponentAccessor.getWatcherManager();

//here we fill an aaray with all requared wathers
UserManager userManager = ComponentAccessor.getUserManager()
List<ApplicationUser> newWatchers = new ArrayList<>();
newWatchers.add(userManager.getUserByName("sam))
newWatchers.add(userManager.getUserByName("elif"))
newWatchers.add(userManager.getUserByName("jack"))

summariesList.each { subTaskSummary ->
MutableIssue newSubTask = issueFactory.getIssue()
newSubTask.setSummary(subTaskSummary)
newSubTask.setParentObject(parentIssue)
newSubTask.setPriorityId(constantManager.getPriorities().find {
it.getName() == "Major"
}?.id)

newSubTask.setProjectObject(parentIssue.getProjectObject())
newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{
it.getName() == "Sub-task"
}.id)
// Add any other fields you want for the newly created sub task

log.debug("New issue ${newSubTask}")
Map<String,Object> newIssueParams = ["issue" : newSubTask] as Map<String,Object>
issueManager.createIssueObject(user, newIssueParams)
subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user)

//here we add watchers for a subtask
newWatchers.each {
watcherManager.startWatching(it, newSubTask)
}

log.info "Issue with summary ${newSubTask.summary} created"
}

Thanos Batagiannis _Adaptavist_
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.
June 21, 2016

hi Elif,

I think Vasiliy's script should work, do you get any errors in your logs ?

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.
June 21, 2016

Hm, try this one and could you provide any info from atlassian-jira.log:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.watchers.WatcherManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
 
def parentIssue = event.issue
if (parentIssue.getIssueType().getName() != 'New User')
    return
 
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def summariesList = ["Subtask0",
                     "Subtask1",
                     "Subtask2 ",
                     " Subtask3",
                     " Subtask4",
                     " Subtask5",
                     " Subtask6",
                     " Subtask7"]
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()
 
WatcherManager watcherManager = ComponentAccessor.getWatcherManager();
 
//here we fill an aaray with all requared wathers
UserManager userManager = ComponentAccessor.getUserManager()
List&lt;ApplicationUser&gt; newWatchers = new ArrayList&lt;&gt;();
newWatchers.add(userManager.getUserByName("Sam user name"))
newWatchers.add(userManager.getUserByName("John user name"))
newWatchers.add(userManager.getUserByName("Jack user name"))
 
summariesList.each { subTaskSummary -&gt;
    MutableIssue newSubTask = issueFactory.getIssue()
    newSubTask.setSummary(subTaskSummary)
    newSubTask.setParentObject(parentIssue)
    newSubTask.setPriorityId(constantManager.getPriorities().find {
        it.getName() == "Major"
    }?.id)
 
    newSubTask.setProjectObject(parentIssue.getProjectObject())
    newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{
        it.getName() == "Sub-task"
    }.id)
    // Add any other fields you want for the newly created sub task
 
    log.debug("New issue ${newSubTask}")
    Map&lt;String,Object&gt; newIssueParams = ["issue" : newSubTask] as Map&lt;String,Object&gt;
    issueManager.createIssueObject(user, newIssueParams)
    subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user)
 
    //here we add watchers for a subtask
    newWatchers.each {
        watcherManager.startWatching(it, newSubTask)
    }
 
    log.info "Issue with summary ${newSubTask.summary} created"
}
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.
June 21, 2016

Could you also provide your JIRA version.

Elif Alverson June 21, 2016

image2016-6-21 10:43:47.png

Elif Alverson June 21, 2016

Vasiliy. now I have the subtasks however subtask 3 has not been assigned to me ( elif ) and Luiz has not been added as the watcher as I requested. 

The JIRA Version is  (v7.1.1#71004-sha1:d6b2c0d). Can you please help me with the assigning subtask 3 to me and adding luiz as watcher. Thank you so much for your understanding.  

Thanos Batagiannis _Adaptavist_
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.
June 21, 2016

Elif

try to add the assignee and the watchers in an if statement, something like 

//if the summary is subtask3 then
if (subTaskSummary.equals("summary3")) {
    def userElif = userManager.getUserByName("Your User Name")
    newSubTask.setAssignee(userElif) //assign it to user with userName
    //add as watchers the users in newWatchers List
	newWatchers.each {
        watcherManager.startWatching(it, newSubTask)
    }
}
Elif Alverson June 21, 2016

Thanos, 

Here is what I ran and no change.

Any ideas? ( please do't hate me)

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.watchers.WatcherManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
  
def parentIssue = event.issue
if (parentIssue.getIssueType().getName() != 'New Employee')
    return
  
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def summariesList = ["Subtask0",
                     "Subtask1",
                     "Subtask2 ",
                     " Subtask3",
                     " Subtask4",
                     " Subtask5",
                     " Subtask6",
                     " Subtask7"]
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()
  
WatcherManager watcherManager = ComponentAccessor.getWatcherManager();
  
//here we fill an aaray with all requared wathers
UserManager userManager = ComponentAccessor.getUserManager()
List&lt;ApplicationUser&gt; newWatchers = new ArrayList&lt;&gt;();
newWatchers.add(userManager.getUserByName("elif"))
newWatchers.add(userManager.getUserByName("luiz"))
newWatchers.add(userManager.getUserByName("elif"))
  
summariesList.each { subTaskSummary -&gt;
    MutableIssue newSubTask = issueFactory.getIssue()
    newSubTask.setSummary(subTaskSummary)
    newSubTask.setParentObject(parentIssue)
    newSubTask.setPriorityId(constantManager.getPriorities().find {
        it.getName() == "Major"
    }?.id)
  
    newSubTask.setProjectObject(parentIssue.getProjectObject())
    newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{
        it.getName() == "Sub-task"
    }.id)
    // Add any other fields you want for the newly created sub task
  
    log.debug("New issue ${newSubTask}")
    Map&lt;String,Object&gt; newIssueParams = ["issue" : newSubTask] as Map&lt;String,Object&gt;
    issueManager.createIssueObject(user, newIssueParams)
    subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user)
  
    //here we add watchers for a subtask
    newWatchers.each {
        watcherManager.startWatching(it, newSubTask)
    }
  
    log.info "Issue with summary ${newSubTask.summary} created"
}
//if the summary is subtask3 then
if (subTaskSummary.equals("summary3")) {
    def userElif = userManager.getUserByName("elif")
    newSubTask.setAssignee(userElif) //assign it to user with userName
    //add as watchers the users in newWatchers List
    newWatchers.each {
        watcherManager.startWatching(it, newSubTask)
    }
}
Thanos Batagiannis _Adaptavist_
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.
June 21, 2016

Elif, try this one and please, if it doesn't work, report back with any errors you may get in your logs. 

UPDATED

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser

def parentIssue = event.issue
if (parentIssue.getIssueType().getName() != 'New Employee')
    return

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def summariesList = ["Subtask0",
                     "Subtask1",
                     "Subtask2",
                     "Subtask3",
                     "Subtask4",
                     "Subtask5",
                     "Subtask6",
                     "Subtask7"]

def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()
def userManager = ComponentAccessor.getUserManager()
def watcherManager = ComponentAccessor.getWatcherManager()

Issue subTask3

//here we fill an array with all required watchers
List&lt;ApplicationUser&gt; newWatchers = new ArrayList&lt;&gt;()
newWatchers.add(userManager.getUserByName("elif"))
newWatchers.add(userManager.getUserByName("luiz"))
newWatchers.add(userManager.getUserByName("jacob"))


summariesList.each { subTaskSummary -&gt;
    MutableIssue newSubTask = issueFactory.getIssue()
    newSubTask.setSummary(subTaskSummary)
    newSubTask.setParentObject(parentIssue)
    newSubTask.setPriorityId(constantManager.getPriorities().find {
        it.getName() == "Major"
    }?.id)

    newSubTask.setProjectObject(parentIssue.getProjectObject())
    newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{
        it.getName() == "Sub-task"
    }.id)
    // Add any other fields you want for the newly created sub task

    //if the summary is subtask3 then
    if (subTaskSummary.equals("Subtask3")) {
        def assignee = userManager.getUserByName("elif")
        newSubTask.setAssignee(assignee)
        Map&lt;String,Object&gt; newIssueParams = ["issue" : newSubTask] as Map&lt;String,Object&gt;
        subTask3 = issueManager.createIssueObject(user, newIssueParams) as Issue
        subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user)
    } else {
        Map&lt;String,Object&gt; newIssueParams = ["issue" : newSubTask] as Map&lt;String,Object&gt;
        issueManager.createIssueObject(user, newIssueParams)
        subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user)
    }

    log.info "Issue with summary ${newSubTask.summary} created"
}

if (subTask3) {
    newWatchers.each {
        watcherManager.startWatching(it, subTask3)
    }
}
Elif Alverson June 21, 2016

Thanos, 

 

 It still does not assign the subtask 3 to me and does not add the watchers to subtask 3. I dont get any errors. Check the screen shot below. Thank you.

 

image2016-6-21 13:2:18.png

Thanos Batagiannis _Adaptavist_
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.
June 21, 2016

Elif I updated the script in my last comment, tested in my local instance. 

Regards

Thanos

Elif Alverson June 21, 2016

Thonas,

When I ran the script you provided above it runs great. I have put the real subtask name instead of Subtask3, here is the error message I am getting below.

 

All I did was the replace suntask3 with the real suBtask name which is " Notify the R Team for New Employee" . Is this happening because there are spaces on the original subtask name?

We are almost there, bare with me !!!!

Thanks so much! 

image2016-6-21 13:55:55.png

Elif Alverson June 21, 2016

Here is the error message from the log files:

 

Time (on server): Tue Jun 21 2016 13:53:54 GMT-0400 (Eastern Daylight Time)

The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.

2016-06-21 13:53:54,564 ERROR [runner.AbstractScriptListener]: *************************************************************************************
2016-06-21 13:53:54,564 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: <inline script>
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script224.groovy: 55: expecting '}', found 'Employee' @ line 55, column 37.
           Notify the Risk Team of New Employee = issueManager.createIssueObject(user, newIssueParams) as Issue
                                       ^
1 error
Thanos Batagiannis _Adaptavist_
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.
June 21, 2016

Elif the subtask3 is a variable (probably a bad one) and in variables spaces are not allowed. you can rename it in line 24 (as you almost did) to let's say

Issue notfy_the_risk_team 

and then use it again in line 55

notfy_the_risk_team = issueManager.createIssueObject(user, newIssueParams) as Issue

Elif Alverson June 22, 2016

Thanos, 

Here is the one I run, and it creates the subtasks however it does not assign the "Notify the Risk Team of New Employee" to any assignee and it does not add the watchers to that subtask. However it creates the subtasks and there are no error messages about the naming. 

Any ideas?

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
 
def parentIssue = event.issue
if (parentIssue.getIssueType().getName() != 'New Employee')
    return
 
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def summariesList = ["Subtask 1",
                     "Subtask 2",
                     "Notify the Risk Team of New Employee",
                     "Subtask 3"] 
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()
def userManager = ComponentAccessor.getUserManager()
def watcherManager = ComponentAccessor.getWatcherManager()
 
Issue Notify_the_Risk_Team_of_New_Hire
 
//here we fill an array with all required watchers
List&lt;ApplicationUser&gt; newWatchers = new ArrayList&lt;&gt;()
newWatchers.add(userManager.getUserByName("susie"))
newWatchers.add(userManager.getUserByName("elif"))
newWatchers.add(userManager.getUserByName("luiz"))
 
 
summariesList.each { subTaskSummary -&gt;
    MutableIssue newSubTask = issueFactory.getIssue()
    newSubTask.setSummary(subTaskSummary)
    newSubTask.setParentObject(parentIssue)
    newSubTask.setPriorityId(constantManager.getPriorities().find {
        it.getName() == "Major"
    }?.id)
 
    newSubTask.setProjectObject(parentIssue.getProjectObject())
    newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{
        it.getName() == "Sub-task"
    }.id)
    // Add any other fields you want for the newly created sub task
 
    //if the summary is Notify¬_the_Risk_Team_of_New_Hire then
    if (subTaskSummary.equals("Notify the Risk Team of New Hire")) {
        def assignee = userManager.getUserByName("susie")
        newSubTask.setAssignee(assignee)
        Map&lt;String,Object&gt; newIssueParams = ["issue" : newSubTask] as Map&lt;String,Object&gt;
        Notify_the_Risk_Team_of_New_Hire = issueManager.createIssueObject(user, newIssueParams) as Issue
        subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user)
    } else {
        Map&lt;String,Object&gt; newIssueParams = ["issue" : newSubTask] as Map&lt;String,Object&gt;
        issueManager.createIssueObject(user, newIssueParams)
        subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user)
    }
 
    log.info "Issue with summary ${newSubTask.summary} created"
}
 
if (Notify_the_Risk_Team_of_New_Hire) {
    newWatchers.each {
        watcherManager.startWatching(it, Notify_the_Risk_Team_of_New_Hire)
    }
}
Thanos Batagiannis _Adaptavist_
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.
June 22, 2016

Elif line 51 it compares summaries, it should match the summary as you have it in the summariesList, therefore:

if (subTaskSummary.equals("Notify the Risk Team of New Employee")) {

//rest of the code ....

}

Elif Alverson June 22, 2016

Thanos, 

THANK YOU SO VERY MUCH!!!!

You are awesome. 

Elif Alverson February 24, 2017

@Thanos Batagiannis [Adaptavist]; I am back and I need your help again! As you know we are using the script above for New Employee issuetype that you kindly provided in the past.

We would like to have subtask 1 and 2 with descriptions as it stated below every time we receive new employee ticket. Is it possible to have subtask 1 and 2 with the descrptions below?

Your help is greatly appreciated.

Description for Subtask 1:

To Do List 1

  • Active Application Add-ins     Lists the extensions that are registered and currently running in your Office program.

  • Inactive Application Add-ins     Lists the add-ins that are present on your computer but are not currently loaded. For example, smart tags or XML Schemas are active only when the document that references them is open. Another example is the COM add-ins that are listed in the COM Add-ins dialog box. If the check box for a COM add-in is selected, the add-in is active. If the check box for a COM add-in is cleared, the add-in is inactive. To learn how to open the COM Add-in dialog box, see the section called Turn off or manage the installed add-ins.

  • Document Related Add-ins     Lists template files that are referenced by currently open documents.

  • Disabled Application Add-ins     Lists add-ins that were automatically disabled because they are causing Office programs to crash.

Description for Subtask 2:

To Do list 2:

  • Active Application Add-ins     Lists the extensions that are registered and currently running in your Office program.

  • Inactive Application Add-ins     Lists the add-ins that are present on your computer but are not currently loaded. For example, smart tags or XML Schemas are active only when the document that references them is open. Another example is the COM add-ins that are listed in the COM Add-ins dialog box. If the check box for a COM add-in is selected, the add-in is active. If the check box for a COM add-in is cleared, the add-in is inactive. To learn how to open the COM Add-in dialog box, see the section called Turn off or manage the installed add-ins.

  • Document Related Add-ins     Lists template files that are referenced by currently open documents.

  • Disabled Application Add-ins     Lists add-ins that were automatically disabled because they are causing Office programs to crash.

Elif Alverson February 27, 2017

Thanos Batagiannis [Adaptavist] , do you have any idea how to add automated description field on the script that has been provided by you? Thank you very much for your help!

0 votes
Elif Alverson June 21, 2016

Here is the script I am using to create New User issue type. I would like to assign subtask 3 to Sam and add John and Jack as watchers to it. 

 

Thank you so much!

 

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.MutableIssue

 

def parentIssue = event.issue

if (parentIssue.getIssueType().getName() != 'New User')

    return

 

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def summariesList = ["Subtask0",

                     "Subtask1",

                     "Subtask2 ",

                     " Subtask3",

                     " Subtask4",

                     " Subtask5",

                     " Subtask6",

                     " Subtask7"]

def issueFactory = ComponentAccessor.getIssueFactory()

def subTaskManager = ComponentAccessor.getSubTaskManager()

def constantManager = ComponentAccessor.getConstantsManager()

def issueManager = ComponentAccessor.getIssueManager()

 

summariesList.each { subTaskSummary ->

    MutableIssue newSubTask = issueFactory.getIssue()

    newSubTask.setSummary(subTaskSummary)

    newSubTask.setParentObject(parentIssue)

    newSubTask.setPriorityId(constantManager.getPriorities().find {

        it.getName() == "Major"

    }?.id)

 

    newSubTask.setProjectObject(parentIssue.getProjectObject())

    newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{

        it.getName() == "Sub-task"

    }.id)

    // Add any other fields you want for the newly created sub task

 

    log.debug("New issue ${newSubTask}")

    Map<String,Object> newIssueParams = ["issue" : newSubTask] as Map<String,Object>

    issueManager.createIssueObject(user, newIssueParams)

    subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user)

        log.info "Issue with summary ${newSubTask.summary} created"

}

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.
June 21, 2016

I am not good with pyton, but I think that if you publish your code here it will make easier ti help you.

TAGS
AUG Leaders

Atlassian Community Events