The each closure is a groovy loop, similar to a java for loop.
It does not return the result of what you do inside the loop. It returns the list itself.
If you want to return some result based on logic you do on each item in the closure, you probably want the any closure
You are using the triggering issue variable which holds “TEST-1” inside the every closure instead of the subtask closure scoped variable, so I am not sure that it is working how you want it to.
Also, you set a variable outside the closure from inside every loop. You can use the return of every as the variable value.
Maybe you want something like this:
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.issueManager
def issueKey = 'TEST-2'
def issue = issueManager.getIssueObject(issueKey)
if(!issue.isSubTask()) {
// if the triggering issue is not a subtask do nothing
return
}
// get all sibling subtasks
def siblingSubtasks = issue.parentObject.getSubTaskObjects()
def verifySiblingSubstaskStatuses = siblingSubtasks.every { subtask ->
//return true if every sibling subtask is in the Resolved state else return false
subtask.status.name == "Resolved"
}
// return true if the triggering sub-task issue contains the word "sometext"
def triggeringIssueSummaryCheck = issue.summary.contains("sometext")
if (triggeringIssueSummaryCheck && verifySiblingSubstaskStatuses) {
return "Perfect!"
} else {
"Something's not right"
}
Also, if checking the issue.resolution is not working, it might be because that status transition to the "Resolution` might not set the resolution field.
You can always raise a support case here if it is still not right and we can work through it via support.