import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.workflow.JiraWorkflow
import com.atlassian.jira.workflow.WorkflowManager
import com.atlassian.jira.event.project.VersionReleaseEvent
import com.atlassian.jira.component.ComponentAccessor
WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager()
ApplicationUser currentUser = ComponentAccessor.getUserManager().getUserByName("JiraBot")
final ACTION_ID_TO_CLOSE = 811
final CommentManager commentManager = ComponentAccessor.getCommentManager()
IssueService issueService = ComponentAccessor.getIssueService()
if (event instanceof VersionReleaseEvent)
{
def event = event as VersionReleaseEvent
def nameVersion = event.version.getName()
Jql newjql = new Jql();
def issues = newjql.getIssuesByJQL("fixVersion ~'${nameVersion}'")
issues.each{
it->
JiraWorkflow workflow = workflowManager.getWorkflow(it)
def transitionValidationResult = issueService.validateTransition(currentUser, it.id, ACTION_ID_TO_CLOSE, new IssueInputParametersImpl())
try {
issueService.transition(currentUser, transitionValidationResult)
}
catch(e) {
commentManager.create(issue, currentUser, e.toString(), true)
}
}
}
It work, but he close only 2 issues, 1 issue have error
2022-08-16 15:26:55,172 ERROR [runner.AbstractScriptListener]: *************************************************************************************
2022-08-16 15:26:55,173 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.project.VersionReleaseEvent, file: null
groovy.lang.MissingPropertyException: No such property: issue for class: Script171
at Script171$_run_closure1.doCall(Script171.groovy:34)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at Script171.run(Script171.groovy:25)
pls help, i dont undestand error
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.