I am using an automation for Jira rule to be executed once the user clicks on a button. I would like to automatically create some linked issues once the user clicks on the button but I receive the following error message:
Script function failed on Automation for Jira rule: Script function failed on Automation for Jira rule: UpdateExecutionSummary , file: SuperFeature/rest_superFeatureGenerator.groovy, error: groovy.lang.MissingPropertyException: No such property: issueLinkType for class: SuperFeature.rest_superFeatureGenerator
How can I fix this?
package SuperFeature
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Logger
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.index.IssueIndexManager
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.event.issue.IssueEventManager
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent
import com.atlassian.jira.event.issue.link.IssueLinkDeletedEvent
import org.apache.log4j.Level
import org.apache.log4j.Logger
import com.atlassian.jira.issue.link.IssueLinkType
def 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.jiraAuthenticationContext
if (issue.getComponents().size()==0){
log.warn("MOUNA CAMELIA COMPONENTS")
issue.update {
String text= "Issue does not have any components\n"
setCustomFieldValue('Execution Summary', text)
}
}else if(issue.getFixVersions().size()==0){
log.warn("MOUNA CAMELIA VERSIONS")
issue.update {
String text= "Issue does not have any fix versions\n"
setCustomFieldValue('Execution Summary', text)
}
}
else{
log.warn("MOUNA CAMELIA 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 issue
def issueManager = ComponentAccessor.issueManager
def issueFactory = ComponentAccessor.issueFactory
def subTaskManager = ComponentAccessor.subTaskManager
def issueLinkManager = ComponentAccessor.issueLinkManager
def userManager = ComponentAccessor.userManager
MutableIssue newIssue= ComponentAccessor.issueFactory.issue
newIssue.setProjectObject(issue.getProjectObject())
newIssue.setSummary("MOUNA CAMELIA")
newIssue.issueTypeId= 19
newIssue.setAssignee(userManager.getUserByName("mouh"))
newIssue.setDescription(issue.getDescription())
for(String component: componentList){
log.warn("MOUNA CAMELIA component"+ component +" NEW ISSUE "+ newIssue)
log.warn("MOUNA CAMELIA Component "+ component+" issue.getId() "+ issue.getId()+" issueLinkType "+issueLinkType+" sequence "+ sequence)
issueLinkManager.createIssueLink(issue.getId(), newIssue.getId(), issueLinkType, sequence, authenticationContext.getLoggedInUser())
}
}
For one on the last few lines of the code you have
for(String component: componentList){
log.warn("MOUNA CAMELIA component"+ component +" NEW ISSUE "+ newIssue)
log.warn("MOUNA CAMELIA Component "+ component+" issue.getId() "+ issue.getId()+" issueLinkType "+issueLinkType+" sequence "+ sequence)
issueLinkManager.createIssueLink(issue.getId(), newIssue.getId(), issueLinkType, sequence, authenticationContext.getLoggedInUser())
}
The issueLinkType
and sequence
referred to in those statements aren't defined anywhere in the code. Hence those will throw a MissingPropertyException when executed.
Maybe you meant issue.issueLinkType
or issue.sequence
?