我正在为 Jira 编写一个 groovy 脚本——我正在从一个问题中收集评论列表,并存储最后一条评论的用户名。
例子:
import com.atlassian.jira.component.ComponentAccessor
def commentManager = ComponentAccessor.getCommentManager()
def comments = commentManager.getComments(issue)
if (comments) {
comments.last().authorUser
}
有时,我不想存储用户名(如果它属于预定义角色)。基本上,我想先检查评论,然后从列表中删除任何符合我标准的评论,然后调用 last().authorUser。就像是:
comments.each {
if (it.authorUser.toString().contains(user.toString())) {
// Here is where I'd want to remove the element from the list**
}
}
comments.last().authorUser // then store the last element as my most recent comment.
有道理?我是 Groovy 的新手——所以我完全怀疑这会让人头疼。我遇到的大多数示例都涉及数字检查……有点难过。