Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

add a postfix to a string v.getName() for a collection of strings in groovy for Jira scriptrunner

Mouna Hammoudi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 26, 2023

I would like to add a postfix called "-Inbox" to each of the elements of a collection of strings. Here is my current approach:

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)      
                
 }

Is there a simpler approach that I could use to avoid the loop, the action I am doing is repetitive and takes time and I would like to find a new approach. I just need to create a new varaible called mynewVersions which is identical to matchedVersions with the only difference being that the name of each version has the postfix "-Inbox" appended.

0 answers

Suggest an answer

Log in or Sign up to answer