I have an active choice parameter called “Fruits” which is set to return a list in the groovy script. The list is defined as below
def FruitList=[‘fruitFilepath1’:‘fruitName1’,‘fruitFilepath2’:‘fruitName2’,‘fruitFilepath3’:‘fruitName3’]
return FruitList
Here, the first value is a path to a file and second value is the name of the fruit.
In “Build with parameters” page, as expected this parameter is displayed as dropdown with values fruitName1, fruitName2, fruitName3.
When the build is run, $Fruits gives me the file path for the selected fruit name. Which is correct.
But I also need the selected fruit name to set it as build name. How do I do this?
For example in the above list if the user selects fruitName1 then build name needs to be set to fruitName1.
I do not have the option to change the format of the above list.
Is there anyway I can do this without installing any plugins or pipeline job ?
Also, I need to maintain only one copy of the FruitList.