I would like to automatically create a Story when an Epic is created.
The following also needs to happen:
I am using Script Runner
Hello,
On the Create transition on the Epic Workflow, add a post function.
As you are using script runner, Select Scripted post function and select Clones an issue, and links
This is will you automatically create a linked issue.
For the story to have the same summary as epic:
In the Additional issue actions box add issue.summary = sourceIssue.summary
Come on @Nisha Hajamohideen , Shwan is asking to set the epic link, not the linking issue.
@Shawn DanisaYou need to add a custom script which will link your story to the epic.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Nisha Hajamohideen I did that. However, this feature is limited to "Issue Linking" dependency. I would like to automatically populate the Epic Link on the story with the Epic (Source) Key
@Maitrey Patel : This the script I tried. Created a custom listener to be executed on Issue Create. However, I didnt get any joy. Please see my script below:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
// func
def linkIssueToEpic(MutableIssue issue, Issue epicIssue, ApplicationUser user)
{
def customFieldManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def epicLinkField = customFieldManager.getCustomFieldObjects(issue).find { it.name == 'Epic Link' }
issue.setCustomFieldValue(epicLinkField, epicIssue)
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Shawn Danisa,
You can achieve this using following script in post function:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.util.ImportUtils
import com.atlassian.crowd.embedded.api.User;
import com.opensymphony.workflow.WorkflowContext
import org.apache.log4j.Category
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
def sourceIssue = issue
def epicIssue = sourceIssue
def epicLink = customFieldManager.getCustomFieldObjectByName("Epic Link")
def projectMgr = ComponentAccessor.getProjectManager()
def PROJECT_KEY_TO = "<<DESTINATION PROJECT KEY>>"
def projectTo = ComponentAccessor.getProjectManager().getProjectByCurrentKey(PROJECT_KEY_TO)
def currentUserObj = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueFactory = ComponentAccessor.getIssueFactory()
def newIssue = issueFactory.cloneIssue(epicIssue)
newIssue.setSummary ("New Story " + epicIssue.summary)
newIssue.setIssueTypeId("3") //3 == TASK - SET ACCORDINGLY 6 for STORY
newIssue.assignee = ComponentAccessor.getUserUtil().getUserByKey("user.name") //Set assignee if you want.
// set the project and any field you want to have a different value
newIssue.setProjectObject(projectTo)
Map<String,Object> newIssueParams = ["issue":newIssue] as Map<String,Object>
issueManager.createIssueObject(user, newIssueParams)
// Following code is used to link task and epic. with 10630 as is implemented by.
epicLink.updateValue(null, newIssue, new ModifiedValue(newIssue.getCustomFieldValue(epicLink), epicIssue),new DefaultIssueChangeHolder())
def linkMgr = ComponentAccessor.getIssueLinkManager()
linkMgr.createIssueLink(newIssue.getId(), epicIssue.getId(), 10630, 1, user);
log.info "Issue ${newIssue?.key} cloned to project ${projectTo.key}"
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.