Hi Manikandan,
The script below will create an issue and it will add it to the sprint that started and triggered the event.
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("SSPA")
def bugIssueType = ComponentAccessor.constantsManager.getAllIssueTypeObjects().find { it.getName() == "Bug" }
def highPriority = ComponentAccessor.getComponent(PriorityManager).getPriority("High")
def reporter = ComponentAccessor.userManager.getUserByKey("anuser")
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)
So eventually your listener will listen for Sprint Started event and the script will be the above.
I'll agree with Anton that a use case will be more helpful.
PS. In your question's title you say sprint create event which is a different event than the Sprint Started Event.
So your custom script listener will look like
Hope that helps,
Thanos
@Thanos Batagiannis [Adaptavist] - Thanks this helps to move forward.
I receive below error after configuration.Let me know your suggestions
Time (on server): Wed Nov 08 2017 15:31:58 GMT-0500 (Eastern Standard Time)
The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.
2017-11-08 20:31:58,570 ERROR [runner.AbstractScriptListener]: ************************************************************************************* 2017-11-08 20:31:58,570 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.greenhopper.api.events.sprint.SprintStartedEvent, script: com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.FireEventWhen java.lang.IllegalArgumentException: The issue object was not available in the binding, perhaps called from an event handler with a non-issue event at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.FireEventWhen.doScript(FireEventWhen.groovy:72)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Manikandan,
The listener should be a 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.
I have a similar requirement but unfortunatly can't find any Sprint..Event.
I'm using Jira Software 7.0.4. with ScriptRunner 5.1.6
Did this event appear with a later version?
Regards,
Christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Christian Bär do you solve "event.sprint" problem?
@Thanos Batagiannis [Adaptavist] custom listener dosn't work for me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Christian Bär (sorry for the late response) and @nick.rozhdestvensky
What if you navigate at <base_url>/rest/scriptrunner/latest/events?perRepo=false, do you see any Jira Software events ?
Also can you please clarify what you mean when you say "the script doesn't work for you", in which sense ? Do you get any errors in your application logs ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Thanos Batagiannis [Adaptavist]
do you see any Jira Software events ?
Yes, a lot.
Do you get any errors in your application logs ?
In line "event.sprint" I have an error "No such property: sprint for class: com.atlassian.jira.event.issue.IssueEvent". Becase SR's binding event is IssueEvent type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi all,
I do not remember where I needed it and if, how I solved it - unfortunately.
Hm, I think I used a button somehow to trigger my code manually.
But I remember that I did not see any Sprint...Event as given in the screenshot above, so that was my question then.
But thanks for the hints, even if late ;-)
Cheers, Christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok I see, so this is a 'false' alarm because of the Static Type Checking
therefore you can either ignore it, or you can cast the event variable to the right type. Something like
import com.atlassian.greenhopper.api.events.sprint.AbstractSprintEvent
def event = event as AbstractSprintEvent
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.
@Thanos Batagiannis [Adaptavist]Hi can you please help me on . When a user clicks on sprint complete button . In the back end a field Goal is set to some text data programmatically . Can you help me on this thanks. Harish
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Am i right - you want to create issue in some project when clicked "Start sprint" on the board?
Could you please provide more details - what problem are you trying to solve?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes. You are right. I would like to create an issue, when i click Start Sprint. a Default issue type "Feature" will be added to the Sprint.
I tried its not working as expected in the script runner. Need some help on it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry for adding this comment now, I'm trying to achieve the same thing but I'm getting the following error at 16. please help
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.