Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,367,386
Community Members
 
Community Events
168
Community Groups

error listener VersionREasleaseEvent

I have listener 

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 

1 answer

1 accepted

0 votes
Answer accepted

the error occurred because a problem with another workflow got into the task type, i think my each broken

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events