Quantcast
Viewing latest article 10
Browse Latest Browse All 279

Generate issue links in Jira with scriptrunner

I am trying to generate some issue links in jira, here is my code. This code is executed as a Jira automation rule after clicking on a button. The problem is that I receive the following error message. They say that the issuelinktype is wrong, anyone knows how to figure out which issue link type I need?

Image may be NSFW.
Clik here to view.
enter image description here
package SuperFeatureimport com.atlassian.jira.bc.project.component.ProjectComponent

import com.atlassian.jira.issue.fields.CustomFieldimport com.atlassian.jira.issue.Issueimport org.apache.log4j.Loggerimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.IssueManagerimport com.atlassian.jira.util.ImportUtilsimport com.atlassian.jira.issue.CustomFieldManagerimport com.atlassian.jira.issue.MutableIssueimport com.atlassian.jira.issue.index.IssueIndexManagerimport com.atlassian.jira.issue.link.IssueLinkManagerimport com.atlassian.jira.issue.index.IssueIndexingServicedef log = Logger.getLogger('atlassian-jira.log')log.warn("MOUNA: ")log.warn("MOUNA COMPONENT NUMBERS : "+ issue.getComponents().size())List<String> componentList = new ArrayList<String>()def authenticationContext = ComponentAccessor.jiraAuthenticationContextif (issue.getComponents().size()==0){    issue.update {    String text= "Issue does not have any components\n"    setCustomFieldValue('Execution Summary', text)    }}else if(issue.getFixVersions().size()==0){            issue.update {                String text= "Issue does not have any fix versions\n"                setCustomFieldValue('Execution Summary', text)                }}else{        int componentSize=issue.getComponents().size()        for(ProjectComponent component : issue.getComponents()) {                componentList.add(component.getName())        }        issue.update {            String text= "The super feature "+issue+" will be split into "+componentSize+" features, one for each component:\n"            for(String component: componentList){                text = text +"-"+ component+"\n";             }            setCustomFieldValue('Execution Summary', text)}// Issue issuedef issueManager = ComponentAccessor.issueManagerdef issueFactory = ComponentAccessor.issueFactorydef subTaskManager = ComponentAccessor.subTaskManagerdef issueLinkManager = ComponentAccessor.issueLinkManagerdef userManager = ComponentAccessor.userManager// Defining subtaskdef newIssue = issueFactory.getIssue()newIssue.setParentId(issue.getId())log.warn("MOUNA CAMELIA issue.getId()"+ issue.getId())def Long issueLinkType = new Long (10001)def Long sequence = new Long (1)newIssue.setProjectObject(issue.getProjectObject())newIssue.setSummary("MOUNA CAMELIA")newIssue.setAssignee(userManager.getUserByName("mouh"))newIssue.setDescription(issue.getDescription())                for(String component: componentList){                    def subTask = issueManager.createIssueObject(authenticationContext.getLoggedInUser(), newIssue)                    subTaskManager.createSubTaskIssueLink(issue, subTask, authenticationContext.getLoggedInUser())                    issueLinkManager.createIssueLink(issue.getId(), newIssue.getId(), issueLinkType, sequence, authenticationContext.getLoggedInUser())        }}

Viewing latest article 10
Browse Latest Browse All 279

Trending Articles