我正在使用 Jira 规则的自动化功能,在用户单击按钮后执行。我想在用户单击按钮后自动创建一些链接的问题,但我收到以下错误消息:
Automation for Jira 规则的脚本功能失败: 脚本函数在 Automation for Jira 规则上失败: UpdateExecutionSummary ,文件: SuperFeature/rest_superFeatureGenerator.groovy,错误:groovy.lang.MissingPropertyException:没有此类属性:类的 issuesLinkType:SuperFeature.rest_superFeatureGenerator
我该如何解决这个问题?
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(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())
}
这些语句中引用的
issueLinkType
和 sequence
未在代码中的任何位置定义。因此,它们在执行时会抛出 MissingPropertyException。
也许您的意思是
issue.issueLinkType
或issue.sequence
?