提问人:Mouna Camelia Hammoudi 提问时间:9/26/2023 更新时间:9/27/2023 访问量:22
为 Groovy for Jira scriptrunner 中的字符串集合的字符串添加后缀 v.getName()
add a postfix to a string v.getName() for a collection of strings in groovy for Jira scriptrunner
问:
我想为字符串集合的每个元素添加一个名为“-Inbox”的后缀。这是我目前的方法:
def matchedVersions = issue.getFixVersions().intersect(
newIssueproject.getVersions(),
Version.NAME_COMPARATOR
)
def mynewVersions = new ArrayList <Version> ()
for( Version v: matchedVersions){
Version mynewVersion= ComponentAccessor.versionManager.createVersion(v.getName()+"-Inbox", startDate, releaseDate, description, newIssueproject.id, scheduleAfterVersion, released)
mynewVersions.add(mynewVersion)
}
有没有一种更简单的方法来避免循环,我正在做的动作是重复的,需要时间,我想找到一种新的方法。我只需要创建一个新的变量,它与之相同,唯一的区别是每个版本的名称都附加了后缀“-Inbox”。mynewVersions
matchedVersions
答:
1赞
injecteer
9/27/2023
#1
一些带有列表操作和方法的右调的简单时髦:createVersion()
def versionCreator = ComponentAccessor.versionManager.&createVersion.rcurry( startDate, releaseDate, description, newIssueproject.id, scheduleAfterVersion, released )
def mynewVersions = issue.fixVersions.intersect( newIssueproject.versions, Version.NAME_COMPARATOR ).collect{ versionCreator it.name + '-Inbox' }
评论