Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Automate rule to create Bug issue type any time a sprint is created

I would like to create a Automated  rule to trigger a Bug issue type any time a sprint is created. The bug issue type Should be part of the sprint and should go inside the sprint\be part of the sprint and not to pulled from the backlog.

I need a bug issue type to be created with  certain fields . I would also want the Bug issue type to use the  customized work flow I currently have for bug issue type (In my customized work flow condition  I have added post functions, Subtask blocking condition, validators etc).

1 answer

Hey @Garden16_ 

Please check this out this thread which has similar use case.

You have to use "Custom Listeners" and use "SprintCreatedEvent"

Please check the script to be written here, you may have to modify bit to add fields and fill their values to get it working:




Just checked out the script too, it worked and created a "Bug" issue and added to the Sprint also

this listener stopped working . I getting the following error






7 ERROR [runner.AbstractScriptListener]: *************************************************************************************
2022-01-19 10:17:49,888 ERROR [runner.AbstractScriptListener]: Script function failed on event:, file: null
com.atlassian.jira.exception.CreateException: Error occurred while creating issue through workflow:
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssueObject(
at com.atlassian.jira.issue.managers.RequestCachingIssueManager.createIssueObject(
at com.atlassian.jira.issue.IssueManager$createIssueObject$ Source)
Caused by: [InvalidInputException: [Error map: [{assignee=Bug must be assigned }]] [Error list: [[]]]
at com.onresolve.scriptrunner.canned.jira.utils.ScopeAwareExceptionMapper.convertException(ScopeAwareExceptionMapper.groovy:26)
at com.onresolve.scriptrunner.canned.jira.utils.ScopeAwareExceptionMapper$ Source)
at com.onresolve.jira.groovy.GroovyValidator.validate(GroovyValidator.groovy:56)
at com.atlassian.jira.workflow.SkippableValidator.validate(
at com.opensymphony.workflow.AbstractWorkflow.verifyInputs(
at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(
at com.opensymphony.workflow.AbstractWorkflow.initialize(
at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(
... 5 more

This is my code 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.PriorityManager

def issueFactory = ComponentAccessor.getIssueFactory()
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser

def newIssue = issueFactory.getIssue()
def project = ComponentAccessor.projectManager.getProjectByCurrentKey("QBT")
def bugIssueType = ComponentAccessor.constantsManager.getAllIssueTypeObjects().find { it.getName() == "Bug" }
def highPriority = ComponentAccessor.getComponent(PriorityManager).getPriority("High")
def sprintCF = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Sprint")

newIssue.setCustomFieldValue(sprintCF, [event.sprint]) //add the issue to the sprint that just started and triggered the event
//... any other fields

Map<String,Object> newIssueParams = ["issue" : newIssue] as Map<String,Object>
ComponentAccessor.issueManager.createIssueObject(loggedInUser, newIssueParams)

Can you look into the log 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

55 views 0 1
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you