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).
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:
https://community.atlassian.com/t5/Jira-questions/Sprint-Create-Event/qaq-p/667714
Regards,
Vishwas
Just checked out the script too, it worked and created a "Bug" issue and added to the Sprint also
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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: com.atlassian.greenhopper.api.events.sprint.SprintCreatedEvent, file: null
com.atlassian.jira.exception.CreateException: Error occurred while creating issue through workflow:
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:583)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:487)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssueObject(DefaultIssueManager.java:597)
at com.atlassian.jira.issue.managers.RequestCachingIssueManager.createIssueObject(RequestCachingIssueManager.java:201)
at com.atlassian.jira.issue.IssueManager$createIssueObject$2.call(Unknown Source)
at Script61.run(Script61.groovy:21)
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$convertException.call(Unknown Source)
at com.onresolve.jira.groovy.GroovyValidator.validate(GroovyValidator.groovy:56)
at com.atlassian.jira.workflow.SkippableValidator.validate(SkippableValidator.java:45)
at com.opensymphony.workflow.AbstractWorkflow.verifyInputs(AbstractWorkflow.java:1466)
at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1167)
at com.opensymphony.workflow.AbstractWorkflow.initialize(AbstractWorkflow.java:606)
at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:754)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:578)
... 5 more
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.setSummary("summary")
newIssue.setProjectObject(project)
newIssue.setIssueType(bugIssueType)
newIssue.setPriority(highPriority)
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you have assignee as a mandatory field on issue creation screen for QBT Project ?
From error log I could see that issue creation failed because of assignee field, so in the script modify to add a default assignee, that should fix the issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
when ever the sprint is created an issue type gets created and it displays display 0 issues. although an issue type is created . How to show issue type on the screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
when ever the sprint is created an issue type gets created and it displays display 0 issues. although an issue type is created . How to show issue type on the screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Let me check this working, actually in my case issue created gets directly added to the sprint.
newIssue.setCustomFieldValue(sprintCF, [event.sprint]) //add the issue to the sprint that just started and triggered the event
The above code should add the issue to the sprint
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It does.But if you look at the screen shot I put , it shows 0 issues
although is created.
I wanted to add date field in the issue that displays the date issue was created
howdo I get it in code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Im checking on my end. It added to the sprint too. I created 2 sprints and it worked both times.
Please see this.
My code in Listeners (Custom Listeners)
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("TSP")
def bugIssueType = ComponentAccessor.constantsManager.getAllIssueTypeObjects().find { it.getName() == "Bug" }
def highPriority = ComponentAccessor.getComponent(PriorityManager).getPriority("High")
def reporter = ComponentAccessor.userManager.getUserByKey("auser")
def sprintCF = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Sprint")
newIssue.setSummary("A summary")
newIssue.setProjectObject(project)
newIssue.setIssueType(bugIssueType)
newIssue.setPriority(highPriority)
newIssue.setReporter(reporter)
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Let me try it again. Also wanted to know how i can get current sprint name in the summary feild
example -
newIssue.setSummary(" Issue type created for '$Sprint name')
I also have custom field name Issue logged date . I want to populate the sprint create date (current date) in this field when ever the issue created.
HHow do I do this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Let me try these 2 things and get back
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great !!
Go inside issue and see if it is part of the new Sprint ?
On other two things I'm unable to get the date and sprint name at the moment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Its created and part of the new sprint. But why does it show 0 issues on the screen. I tried refreshing the screen. Still is shows 0 issues . Did you see my screen shot? It says 0 issues next to the blue color icon. I wanted to know if there is a fix for it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm, i saw the screenshot. Don't know what could be the issue. Can you check what is the query written on the board. In Backlog --> go to configure board -> General.
Maybe the board filter query can be excluding this issue created.
Please try reaching to adaptvist support team they can analyze further on the other two requirements..
https://productsupport.adaptavist.com/servicedesk/customer/portal/2
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My configure Board shows the following query. It shows the issue type that got created . But on the Board it shows 0 issues although there is an issue created .
when I click on the blue icon I see the following results. But the issue count shows 0 issues although there is an automated issue created .
Here are the results of the query board .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I updated the query . Still its showing 0 issues
project = ABC AND issuetype = "BUG" AND created >= -1w ORDER BY cf[10106] ASC, assignee ASC, created DESC
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Query looks fine. both queries are okay.
Are the other issues created in backlog and added to sprint shows in number.
not able to get what is the issue, please check with support team.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was able to add issue type manually and it showed me the count as 1 issue type. But in fact there were two issue types in the sprint .One that was created automatically via the listener and the other that I created manually. I don't know why the issue count is getting displayed anytime the issue created via the custom listener .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.